/**
 * DocuDynamic Stylesheet
 * Modern, clean interface design
 */

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-900);
    background-color: var(--gray-50);
}

/* Inline code styling */
code {
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    color: #374151;
}

/* Code in examples (highlighted) */
.card code {
    font-size: 0.875rem;
}

/* Placeholder code (yellow background) */
code.placeholder {
    background: #fef3c7;
    color: #92400e;
}


/* Header */
.app-header {
    background: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.app-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.app-nav a {
    margin-left: 1.5rem;
    color: var(--gray-600);
    text-decoration: none;
    transition: color 0.2s;
}

.app-nav a:hover {
    color: var(--primary-color);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* File Upload Area */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 0.5rem;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    background-color: var(--gray-50);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #eef2ff;
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--gray-400);
}

.upload-text {
    font-size: 1.125rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.file-input {
    display: none;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger-color);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--gray-900);
    background-color: white;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Field List */
/* Drag and Drop Styles */
.field-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.field-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    cursor: move;
    transition: all 0.2s;
}

.field-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.field-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.field-item.drag-over {
    border-top: 3px solid #3b82f6;
}

.field-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.field-item-header .drag-handle {
    cursor: move;
    color: #9ca3af;
    font-size: 1.25rem;
    margin-right: 0.5rem;
}

.field-name {
    font-weight: 600;
    color: var(--gray-900);
    font-family: 'Courier New', monospace;
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    flex-grow: 1;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Alert */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background-color: var(--gray-100);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-300);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background-color: var(--gray-50);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
}

.badge-primary {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

/* Responsive */
@media (max-width: 768px) {
    .field-grid {
        grid-template-columns: 1fr;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .app-nav {
        margin-top: 1rem;
    }
    
    .app-nav a {
        margin-left: 0;
        margin-right: 1rem;
    }
}

/* Authentication Pages */
.auth-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-container {
    width: 100%;
    max-width: 450px;
}

.auth-card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 2.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    font-size: 2.5rem;
    text-decoration: none;
    color: var(--primary-color);
    display: inline-block;
    margin-bottom: 0.5rem;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0.5rem 0;
}

.auth-subtitle {
    color: var(--gray-600);
    margin: 0;
    font-size: 0.95rem;
}

.auth-form {
    margin-top: 1.5rem;
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--gray-600);
    font-size: 0.95rem;
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.password-requirements {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.password-requirements ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.25rem;
}

.password-requirements li {
    margin-bottom: 0.25rem;
}

.auth-features {
    margin-top: 2rem;
    display: grid;
    gap: 1rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 0.75rem;
    color: white;
    backdrop-filter: blur(10px);
}

.feature-icon {
    font-size: 2rem;
}

.feature-item strong {
    display: block;
    margin-bottom: 0.25rem;
}

.feature-item p {
    margin: 0;
    font-size: 0.875rem;
    opacity: 0.9;
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

/* User Menu Dropdown */
#userMenuBtn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

#userMenuBtn:hover {
    background-color: #f3f4f6;
}

#userMenu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    background: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    min-width: 200px;
    z-index: 1000;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

#userMenu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: background-color 0.2s;
    font-size: 0.95rem;
}

#userMenu a:hover {
    background-color: #f9fafb;
}

#userMenu a:not(:last-child) {
    border-bottom: 1px solid #f3f4f6;
}

#userMenu a:last-child {
    color: var(--danger-color);
    border-top: 1px solid var(--gray-200);
}

#userMenu a:last-child:hover {
    background-color: #fef2f2;
}

/* Hover effect for feedback link */
a[href*="feedback.php"]:hover {
    opacity: 1 !important;
    background: rgba(255,255,255,0.2) !important;
    border-color: rgba(255,255,255,0.5) !important;
    transform: translateY(-2px);
}

/* Floating Feedback Button - Simple & Clean */
#floatingFeedbackBtn:hover {
    background: white !important;
    color: #667eea !important;
    border-color: #667eea !important;
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6);
}

/* Mobile responsive */
@media (max-width: 768px) {
    #floatingFeedbackBtn {
        bottom: 20px;
        right: 20px;
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
    
    /* Hide text on mobile, show only icon */
    #floatingFeedbackBtn span:last-child {
        display: none;
    }
}

/* Accessibility: Focus state */
#floatingFeedbackBtn:focus {
    outline: 3px solid #667eea;
    outline-offset: 3px;
}

/* Smooth transitions only */
#floatingFeedbackBtn {
    transition: transform 0.3s ease, 
    background 0.3s ease, 
    color 0.3s ease, 
    box-shadow 0.3s ease,
    border-color 0.3s ease;
}

/* Mobile Menu Styles */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--gray-700);
    font-size: 1.5rem;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 9998;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-menu-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gray-600);
}

.mobile-menu-items {
    padding: 1rem 0;
}

.mobile-menu-items a {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--gray-700);
    text-decoration: none;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s;
}

.mobile-menu-items a:hover {
    background: var(--gray-50);
    color: var(--primary-color);
}

.mobile-menu-items .btn {
    margin: 1rem 1.5rem;
    display: block;
    text-align: center;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9997;
}

.mobile-menu-overlay.active {
    display: block;
}

/* Responsive Header */
@media (max-width: 768px) {
    .app-nav {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .mobile-menu {
        display: block;
    }

    .app-logo {
        font-size: 1.25rem;
    }

    .app-header .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}

/* User submenu in mobile */
.mobile-user-submenu {
    background: var(--gray-50);
    padding: 0.5rem 0;
}

.mobile-user-submenu a {
    padding-left: 2.5rem;
    font-size: 0.95rem;
}

/* Mobile Responsive Styles */
.responsive-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Table Cards */
@media (max-width: 768px) {
    /* Hide table headers on mobile */
    #templatesList thead {
        display: none;
    }

    /* Make table rows display as cards */
    #templatesList tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--gray-200);
        border-radius: 0.5rem;
        padding: 1rem;
        background: white;
    }

    #templatesList tbody td {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        border: none;
    }

    /* Add labels to data on mobile */
    #templatesList tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        display: inline-block;
        width: 120px;
        color: var(--gray-700);
    }

    #templatesList tbody td:last-child {
        padding-top: 1rem;
        border-top: 1px solid var(--gray-200);
        margin-top: 0.5rem;
    }

    /* Action buttons full width on mobile */
    #templatesList .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    #templatesList .action-buttons .btn {
        width: 100%;
        text-align: center;
    }

    /* Card header responsive */
    .card-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch !important;
    }

    .card-header .btn {
        width: 100%;
    }

    /* Info cards stack on mobile */
    .info-cards {
        grid-template-columns: 1fr !important;
    }

    /* Alert padding on mobile */
    .alert {
        padding: 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Retention policy cards stack */
    .retention-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Tablet adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .info-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}