/* =================================
   BASE STYLES
   ================================= */

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

body {
    font-family: var(--font-family-sans);
    background: var(--color-background);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden auto;
    color: var(--color-text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

/* Animation keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =================================
    UNIFIED HEADER STYLES
    ================================= */

/* Unified page header for all pages */
.page-header {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-block-end: var(--space-6);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--space-5);
}

.header-tree-rings {
    position: relative;
    overflow: hidden;
}

.header-tree-rings::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--header-tree-rings-image);
    background-repeat: no-repeat;
    background-position: center 50%;
    background-size: 100% auto;
    opacity: 0.1;
    filter: grayscale(1);
    pointer-events: none;
}

.header-tree-rings > * {
    position: relative;
    z-index: 1;
}

.page-header--decorated {
    background: var(--color-gray-800);
    border-color: var(--color-gray-700);
    box-shadow: var(--shadow-lg);
    color: var(--color-gray-100);
}

.page-header--decorated .page-title {
    color: var(--color-gray-100);
}

.page-header--decorated .page-subtitle {
    color: var(--color-gray-300);
}

/* Header content area - supports both simple and complex layouts */
.header-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Brand mark pill badge above page title */
.page-brand-mark {
    display: inline-flex;
    align-items: center;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.73rem;
    color: #9fb89a;
    border: 1px solid rgb(159, 184, 154, 0.32);
    border-radius: 999px;
    background: rgb(22, 33, 22, 0.84);
    padding: 0.42rem 0.88rem;
    font-weight: 600;
}

/* Page title */
.page-title {
    margin: 0;
    color: var(--color-text-primary);
    font-size: var(--font-size-3xl);
    font-weight: 600;
}

/* Page subtitle */
.page-subtitle {
    color: var(--color-text-secondary);
    margin-block: var(--space-1) 0;
    margin-inline: 0;
    font-size: var(--font-size-base);
    font-weight: 400;
}

/* Header actions */
.header-actions {
    display: flex;
    gap: var(--space-4);
    align-items: center;
}

/* Disabled navigation buttons */
.btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Current page indicator */
.btn[aria-current="page"] {
    background: var(--color-accent-gradient);
    color: #fff;
    border-color: var(--color-blue-600);
}

/* Responsive header */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .header-actions {
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--space-3);
    }

    .header-content {
        align-items: center;
        text-align: center;
    }

    .breadcrumb {
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    /* Stack navigation buttons vertically on very small screens */
    @media (max-width: 480px) {
        .header-actions {
            flex-direction: column;
            align-items: center;
        }

        .breadcrumb {
            font-size: var(--font-size-xs);
        }
    }
}
/* =================================
   LAYOUT STYLES
   ================================= */

/* NEW MAP-PRIMARY LAYOUT */
.main-container {
    display: flex !important;
    height: 100vh !important;
    overflow: hidden !important;
}

.header {
    background: var(--color-surface);
    color: var(--color-text-primary);
    padding-block: var(--space-6);
    padding-inline: var(--space-8);
    text-align: center;
    border-block-end: 1px solid var(--color-border);

    h1 {
        font-size: var(--font-size-3xl);
        margin-block-end: var(--space-2);
        font-weight: 600;
        color: var(--color-text-primary);
    }

    p {
        font-size: var(--font-size-base);
        color: var(--color-text-secondary);
        font-weight: 400;
    }
}

.content {
    padding: var(--space-8);
}

/* Form Layout */
.form-section {
    background: var(--color-surface);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    margin-block-end: var(--space-6);
    border: 1px solid var(--color-border);

    h3 {
        color: var(--color-text-primary);
        margin-block-end: var(--space-5);
        font-size: var(--font-size-lg);
        font-weight: 600;
    }
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-5);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.edit-group {
    display: flex;
    flex-direction: column;
}
/* =================================
   COMPONENT STYLES
   ================================= */

/* Tabs */
.tabs {
    display: flex;
    border-block-end: 1px solid var(--color-border);
    margin-block-end: var(--space-6);
    overflow-x: auto;
}

.tab {
    padding-block: var(--space-3);
    padding-inline: var(--space-5);
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab.active {
    color: var(--color-text-primary);
    border-block-end: 2px solid var(--color-blue-600);
    font-weight: 600;
}

.tab:hover {
    color: var(--color-text-primary);
    background: var(--color-gray-50);
}

/* Vertical Tabs */
.tabs.vertical {
    display: flex;
    flex-direction: column;
    border-block-end: none;
    border-inline-end: 1px solid var(--color-border);
    margin: 0;
    background: var(--color-gray-50);
}

.tabs.vertical .tab {
    text-align: start;
    border-block-end: 1px solid var(--color-border);
    border-radius: 0;
    padding-block: var(--space-3);
    padding-inline: var(--space-4);
    transition: all 0.2s ease;
}

.tabs.vertical .tab.active {
    background: var(--color-surface);
    border-inline-end: 2px solid var(--color-blue-600);
    color: var(--color-text-primary);
    border-block-end-color: var(--color-border);
    font-weight: 600;
}

.tabs.vertical .tab:hover {
    background: var(--color-gray-100);
}

/* Forms */
.form-group label {
    font-weight: 500;
    color: var(--color-text-primary);
    margin-block-end: var(--space-1);
    font-size: var(--font-size-sm);
}

.form-group input,
.form-group select {
    padding-block: var(--space-2);
    padding-inline: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    transition: all 0.2s ease;
    background: var(--color-surface);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-blue-600);
    box-shadow: 0 0 0 3px rgb(53, 80, 51, 0.1);
}

.edit-group label {
    font-weight: 500;
    color: var(--color-text-primary);
    margin-block-end: var(--space-1);
    font-size: var(--font-size-xs);
}

.edit-group input {
    padding-block: var(--space-1);
    padding-inline: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    transition: all 0.2s ease;
    background: var(--color-surface);
}

.edit-group input:focus {
    outline: none;
    border-color: var(--color-blue-600);
    box-shadow: 0 0 0 2px rgb(53, 80, 51, 0.1);
}

/* Form improvements for auth modals */
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
}

.form-group small {
    color: var(--color-gray-500);
    font-size: 0.75rem;
    margin-top: 2px;
    display: block;
}

/* Tooltips */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    margin-left: 5px;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: var(--color-gray-700);
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    font-size: 0.75rem;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--color-gray-700) transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}


/* Files filter */
.files-filter select {
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    background: var(--color-surface);
}

/* Empty state */
.files-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-secondary);
}

.helper-text {
    color: var(--color-text-secondary);
}

.error-message {
    color: var(--color-red-700);
}

.field-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-primary);
}

.field-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-input:focus {
    outline: none;
    border-color: var(--color-blue-600);
    box-shadow: 0 0 0 3px var(--color-accent-soft-bg);
}

.field-input:disabled {
    background: var(--color-gray-100);
    color: var(--color-text-secondary);
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .file-metadata {
        flex-wrap: wrap;
        gap: 10px;
    }

    .file-actions {
        justify-content: center;
    }

    .file-actions .btn {
        flex: 1;
        max-width: 70px;
    }

    .files-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
}

/* =================================
   FILE DROPZONE COMPONENT
   ================================= */

.file-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: 6px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    background: transparent;
    transition: border-color 0.15s, background 0.15s;
}

.file-dropzone.is-dragging {
    border-color: #355033;
    background: rgb(53, 80, 51, 0.14);
}

.file-dropzone.is-processing {
    border-color: var(--color-text-muted);
    cursor: default;
}

.file-dropzone-content {
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.file-dropzone-spinner {
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.file-dropzone-filename {
    color: var(--color-text-primary);
}

.file-dropzone-hint {
    color: var(--color-text-secondary);
}
/* =================================
   MODAL STYLES
   ================================= */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgb(7, 11, 7, 0.74);
    backdrop-filter: blur(6px);
    animation: modalFadeIn 0.2s ease;
}

.modal.show {
    display: block;
}

.modal-content {
    --color-surface: #1b2a1d;
    --color-background: #132015;
    --color-border: rgb(149, 173, 144, 0.28);
    --color-border-hover: rgb(149, 173, 144, 0.4);
    --color-text-primary: #edf3ec;
    --color-text-secondary: #c8d7c4;
    --color-text-muted: #95ad90;
    --color-gray-50: #1b2a1d;
    --color-gray-100: #223224;
    --color-gray-200: #304535;
    --color-gray-700: #314735;
    --color-gray-800: #1a271c;
    --color-gray-900: #111811;
    --color-ink-primary: var(--color-text-primary);
    --color-ink-secondary: var(--color-text-secondary);
    --color-ink-muted: var(--color-text-muted);
    --color-green-50: rgb(22, 163, 74, 0.18);
    --color-green-100: rgb(22, 163, 74, 0.26);
    --color-yellow-50: rgb(245, 158, 11, 0.16);
    --color-yellow-100: rgb(245, 158, 11, 0.24);
    --color-red-50: rgb(239, 68, 68, 0.16);
    --color-red-100: rgb(239, 68, 68, 0.24);

    background: linear-gradient(165deg, rgb(26, 39, 28, 0.98), rgb(16, 24, 17, 0.98));
    margin: 3% auto;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 46px rgb(6, 10, 6, 0.52);
    border: 1px solid rgb(149, 173, 144, 0.24);
    color: var(--color-text-primary);
    animation: modalSlideIn 0.2s ease;
}

.modal-content.modal-large {
    max-width: 1200px;
    width: 95%;
    margin: 2% auto;
}

.modal-header {
    background: transparent;
    color: var(--color-text-primary);
    padding-block: var(--space-4);
    padding-inline: var(--space-5);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-block-end: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.modal-body {
    padding: var(--space-5);
    background: transparent;
    color: var(--color-text-secondary);
}

.modal-footer {
    padding-block: var(--space-4);
    padding-inline: var(--space-5);
    border-block-start: 1px solid var(--color-border);
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    background: transparent;
    border-end-start-radius: var(--radius-lg);
    border-end-end-radius: var(--radius-lg);
}

.close {
    color: var(--color-text-muted);
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1;
    opacity: 1;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    padding: 0;
}

.close:hover {
    color: var(--color-text-primary);
    background: rgb(149, 173, 144, 0.18);
}

.close:focus-visible {
    outline: 2px solid var(--color-blue-600);
    outline-offset: 2px;
}
/* =================================
   ITEM STYLES (Sources, Lists, Bulk Operations)
   ================================= */

.source-item {
    --color-surface: var(--color-surface-light);
    --color-background: var(--color-background-light);
    --color-border: var(--color-border-light);
    --color-border-hover: var(--color-border-light-hover);
    --color-text-primary: var(--color-ink-primary);
    --color-text-secondary: var(--color-ink-secondary);
    --color-text-muted: var(--color-ink-muted);

    background: var(--color-surface);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 4px rgb(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    color: var(--color-text-primary);
}

.source-item:hover {
    border-color: var(--color-border-hover);
    box-shadow: 0 4px 8px rgb(64, 96, 59, 0.15);
    transform: translateY(-1px);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.item-title {
    font-weight: 600;
    color: var(--color-text-primary);
    flex-grow: 1;
}

.item-select {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
}
/* =================================
   MESSAGE & NOTIFICATION STYLES
   ================================= */

/* Error and Success States */
.error {
    color: var(--color-red-600);
    font-size: var(--font-size-xs);
    margin-top: var(--space-1);
}

.success {
    color: var(--color-green-600);
    font-size: var(--font-size-xs);
    margin-top: var(--space-1);
}

.error-field {
    border-color: var(--color-red-600) !important;
    box-shadow: 0 0 0 3px rgb(220, 38, 38, 0.1) !important;
}

.field-error {
    color: var(--color-red-600);
    font-size: var(--font-size-xs);
    margin-top: var(--space-1);
    font-weight: 500;
}

/* Message notifications */
.message {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    font-weight: 500;
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-sm);
}

.message-info {
    background: var(--color-blue-50);
    color: var(--color-blue-700);
    border: 1px solid var(--color-border);
}

/* Toast message styles */
.success-message,
.error-message,
.warning-message,
.info-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    z-index: 10001;
    font-weight: 500;
    box-shadow: 0 4px 12px rgb(0, 0, 0, 0.15);
    max-width: 450px;
    word-wrap: break-word;
    white-space: pre-line;
    line-height: 1.4;
    animation: slideInUp 0.3s ease-in-out;
}

.success-message {
    top: 20px;
    bottom: auto;
    background: #d6e1d4;
    color: #40603b;
    border: 1px solid #40603b;
}

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

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

.info-message {
    background: #dbe6d9;
    color: #2d442a;
    border: 1px solid #aac0a6;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}
/* =================================
   AUTHENTICATION STYLES
   ================================= */

/* Auth section in header */
.auth-section {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-right: 10px;
}

.auth-state {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.user-email {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-email-trigger {
    appearance: none;
    background: transparent;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    line-height: inherit;
    text-align: left;
}

.user-email-trigger:focus-visible {
    outline: 2px solid var(--color-blue-500);
    outline-offset: 2px;
}
/* =================================
   RESPONSIVE DESIGN
   ================================= */

@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 15px;
    }

    .content {
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 2rem;
    }

    .item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Modal responsive styles */
    .modal-content {
        width: 95%;
        margin: 2% auto;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 15px 20px;
        flex-direction: column;
    }

    /* Map Layout Responsive */
    .map-header {
        padding: 0;
    }

    .map-header-top {
        padding: 10px 12px;
    }

    .map-title h1 {
        font-size: 14px;
    }

    /* Mobile responsive auth */
    .auth-section {
        margin-right: 5px;
    }

    .user-email {
        max-width: 120px;
        font-size: 0.8rem;
    }

}
