/* CSS Variables for theming - Adjuvo Document Organizer */
:root {
    /* Light theme (default) */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #fafafa;
    --bg-alt: #f4f4f4;
    --bg-header: #e0f7fa;
    --bg-modal: #fff;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    --bg-loading: rgba(255, 255, 255, 0.8);
    --bg-button: #fff;
    --bg-button-hover: #f0f0f0;
    --bg-button-action: #2196F3;
    --bg-button-delete: #dc3545;
    --bg-button-destructive: #c62828;
    --bg-summary: #e3f2fd;
    --bg-section: #fafafa;

    --text-primary: #000;
    --text-secondary: #333;
    --text-tertiary: #666;
    --text-inverse: #ffffff;
    --text-link: #2196F3;

    --border-primary: #ccc;
    --border-secondary: #ddd;
    --border-tertiary: #eee;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #242424;
    --bg-alt: #2a2a2a;
    --bg-header: #1e3a3f;
    --bg-modal: #2d2d2d;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --bg-loading: rgba(0, 0, 0, 0.8);
    --bg-button: #3a3a3a;
    --bg-button-hover: #4a4a4a;
    --bg-button-action: #1976D2;
    --bg-button-delete: #c62828;
    --bg-button-destructive: #b71c1c;
    --bg-summary: #1e3a4a;
    --bg-section: #242424;

    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #888;
    --text-inverse: #ffffff;
    --text-link: #64B5F6;

    --border-primary: #444;
    --border-secondary: #3a3a3a;
    --border-tertiary: #333;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.5);
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-header);
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease;
    z-index: 100;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

button, .btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    cursor: pointer;
    background-color: var(--bg-button);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.1s ease;
}

button:hover, .btn:hover {
    background: var(--bg-button-hover);
    transform: translateY(-1px);
}

button:active, .btn:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.action-btn, button.action-btn, button[type="submit"] {
    background: var(--bg-button-action);
    color: var(--text-inverse);
    border-color: var(--bg-button-action);
}

.btn.action-btn:hover, button.action-btn:hover, button[type="submit"]:hover {
    background: #1976D2;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 0.95rem;
    background: var(--bg-button);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--bg-button-action);
}

.success-message {
    background: #4CAF50;
    color: white;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.error-message {
    background: var(--bg-button-delete);
    color: white;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--border-primary);
    border-top: 3px solid var(--bg-button-action);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.email-list {
    list-style: none;
    padding: 0;
}

.email-item {
    padding: 0.8rem;
    border-bottom: 1px solid var(--border-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.email-item:last-child {
    border-bottom: none;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-success {
    background: #4CAF50;
    color: white;
}

.badge-warning {
    background: #FFC107;
    color: #333;
}

.badge-error {
    background: var(--bg-button-delete);
    color: white;
}

/* Progress Bar */
.progress-bar-bg {
    width: 100%;
    height: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50 0%, #66BB6A 100%);
    border-radius: 12px;
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Schema Tree Viewer */
.schema-folder {
    margin-bottom: 0.5rem;
}

.schema-folder-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.schema-folder-header:hover {
    background: var(--bg-tertiary);
}

.schema-folder-toggle {
    cursor: pointer;
    user-select: none;
    font-size: 0.8rem;
    width: 16px;
    text-align: center;
    transition: transform 0.2s ease;
}

.schema-folder.collapsed .schema-folder-toggle {
    transform: rotate(-90deg);
}

.schema-folder-toggle-spacer {
    width: 16px;
    display: inline-block;
}

.schema-folder-icon {
    font-size: 1rem;
}

.schema-folder-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.schema-folder-meta {
    margin: 0.5rem 0 0.5rem 2rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border-tertiary);
}

.schema-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.schema-files {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.schema-files-label {
    color: var(--text-tertiary);
    font-weight: 500;
    margin-right: 0.25rem;
}

.schema-file-tag {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    margin-right: 0.3rem;
    margin-bottom: 0.3rem;
    border: 1px solid var(--border-tertiary);
}

.schema-folder-children {
    margin-top: 0.3rem;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.schema-folder.collapsed > .schema-folder-children {
    display: none;
}

.schema-folder.collapsed > .schema-folder-meta {
    display: none;
}

/* Schema viewer container updates */
#schema-viewer-content {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid var(--border-secondary);
    max-height: 600px;
    overflow-y: auto;
}

/* Hamburger Menu */
#menu-container {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.dropdown-menu[hidden] {
    display: none !important;
}

.dropdown-menu .menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border: none;
    background: var(--bg-secondary);
    cursor: pointer;
    border-radius: 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: background-color 0.2s ease;
}

.dropdown-menu .menu-item:first-child {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.dropdown-menu .menu-item:last-child {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.dropdown-menu .menu-item:hover {
    background: var(--bg-button-hover);
}

/* Modal Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-overlay);
    z-index: 10000;
}

/* Ensure overlays stay hidden when the hidden attribute is set */
.overlay[hidden] {
    display: none !important;
}

/* Modal Container */
.modal {
    background: var(--bg-modal);
    padding: 1.5rem;
    border-radius: 6px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: background-color 0.3s ease;
    position: relative;
}

/* Modal close button in top-right corner */
.modal-close-x {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    z-index: 1;
}

.modal-close-x:hover {
    background: var(--bg-button-hover);
    color: var(--text-primary);
}

/* Modal styling */
.modal h2 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.modal label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
}

.modal label input,
.modal label select,
.modal label textarea {
    margin-top: 0.5rem;
}

.modal input,
.modal select,
.modal textarea {
    padding: 0.5rem;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background: var(--bg-button);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Modal button styling - use classes, not IDs */
.cancel-btn,
.close-btn {
    background: var(--bg-button);
    color: var(--text-secondary);
    transition: background-color 0.3s ease;
}

.cancel-btn:hover,
.close-btn:hover {
    background: var(--bg-button-hover);
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .container {
        padding: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

    .schema-folder-meta {
        margin-left: 1rem;
        padding-left: 0.5rem;
    }

    .modal {
        padding: 1rem;
        max-height: 85vh;
    }
}
