/* ==========================================================================
   DESIGN SYSTEM & CUSTOM DARK THEME - CABINET ANTOINE AOUN
   ========================================================================== */

:root {
    /* Color Palette (HSL Tailored for harmony) */
    --bg-darker: hsl(222, 47%, 6%);
    --bg-dark: hsl(222, 47%, 9%);
    --bg-card: hsl(223, 40%, 12%);
    --bg-card-hover: hsl(223, 35%, 15%);
    --bg-input: hsl(222, 35%, 14%);
    --border-color: hsla(217, 30%, 20%, 0.6);
    --border-color-glow: hsla(217, 80%, 60%, 0.35);
    
    /* Brand Accent Colors */
    --accent-indigo: hsl(245, 75%, 66%);
    --accent-indigo-glow: hsla(245, 75%, 66%, 0.15);
    --accent-cyan: hsl(190, 90%, 50%);
    --accent-cyan-glow: hsla(190, 90%, 50%, 0.15);
    --accent-emerald: hsl(150, 80%, 40%);
    --accent-emerald-glow: hsla(150, 80%, 40%, 0.15);
    
    /* Text Colors */
    --text-primary: hsl(210, 40%, 96%);
    --text-secondary: hsl(215, 25%, 72%);
    --text-muted: hsl(217, 15%, 52%);
    --text-indigo: hsl(245, 100%, 80%);
    --text-emerald: hsl(150, 90%, 75%);
    
    /* Timing & Animations */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Glassmorphism */
    --glass-bg: rgba(13, 20, 38, 0.45);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-blur: blur(16px);
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, .title-font {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Loader Placeholder */
.initial-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: var(--bg-darker);
}
.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-indigo);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.loader-text {
    margin-top: 20px;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
}

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

/* Glassmorphism Header */
header {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }
}

.brand {
    display: flex;
    flex-direction: column;
}

.brand h1 {
    font-size: 1.75rem;
    background: linear-gradient(135deg, #fff 30%, var(--accent-indigo) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.brand p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.path-badge {
    background: hsla(245, 75%, 66%, 0.1);
    border: 1px solid rgba(245, 75%, 66%, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-indigo);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Control & Search Bar */
.search-controls-section {
    max-width: 1400px;
    margin: 1.5rem auto 0 auto;
    padding: 0 2rem;
}

@media (max-width: 768px) {
    .search-controls-section {
        padding: 0 1rem;
    }
}

.search-controls-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

@media (max-width: 992px) {
    .search-controls-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 500px;
}

.search-box input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 3px var(--accent-indigo-glow);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-fast);
    outline: none;
}

.btn-primary {
    background: var(--accent-indigo);
    color: #fff;
}
.btn-primary:hover {
    background: hsl(245, 75%, 72%);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.btn-success {
    background: var(--accent-emerald);
    color: #fff;
}
.btn-success:hover {
    background: hsl(150, 80%, 46%);
    transform: translateY(-1px);
}

.btn-warning {
    background: #d97706;
    color: #fff;
}
.btn-warning:hover {
    background: #f59e0b;
    transform: translateY(-1px);
}

/* Main Workspace Layout */
.workspace-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem 2rem;
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

@media (max-width: 992px) {
    .workspace-container {
        flex-direction: column;
        padding: 1rem;
    }
}

/* Sidebar Styling */
aside {
    width: 320px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    position: sticky;
    top: 5.5rem;
}

@media (max-width: 992px) {
    aside {
        width: 100%;
        position: static;
    }
}

.sidebar-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.menu-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.menu-item {
    width: 100%;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-fast);
}

.menu-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.menu-item.active {
    background: var(--accent-indigo-glow);
    border: 1px solid rgba(245, 75%, 66%, 0.3);
    color: var(--text-indigo);
}

.menu-item .emoji {
    font-size: 1.2rem;
    margin-right: 0.75rem;
}

.menu-item .count-badge {
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    transition: var(--transition-fast);
}

.menu-item.active .count-badge {
    background: var(--accent-indigo);
    color: #fff;
}

/* Content Area */
.content-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0; /* Prevents flex children from breaking parent bounds */
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.content-header h2 {
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-header .active-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Folders Grid & Cards */
.folders-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.folder-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    transition: var(--transition-normal);
}

.folder-card:hover {
    border-color: var(--border-color-glow);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.folder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    background: hsla(223, 40%, 12%, 0.3);
}

.folder-header:hover {
    background: hsla(223, 40%, 12%, 0.8);
}

.folder-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.folder-info .folder-icon {
    font-size: 1.4rem;
    color: var(--accent-indigo);
}

.folder-info h4 {
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.folder-actions .badge {
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.toggle-arrow {
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: transform var(--transition-normal);
}

.toggle-arrow.open {
    transform: rotate(90deg);
}

.folder-content {
    border-top: 1px solid var(--border-color);
    background: hsla(222, 47%, 7%, 0.5);
    overflow: hidden;
    transition: max-height var(--transition-normal) ease-in-out;
}

/* Files inside folders */
.files-table {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    transition: var(--transition-fast);
}

.file-row:hover {
    background: var(--bg-card-hover);
}

.file-row-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex-grow: 1;
}

.file-ext-badge {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    min-width: 42px;
    text-align: center;
}

/* File ext specific designs */
.ext-pdf { background: rgba(239, 68, 68, 0.15); color: rgb(248, 113, 113); border: 1px solid rgba(239, 68, 68, 0.2); }
.ext-epub { background: rgba(59, 130, 246, 0.15); color: rgb(96, 165, 250); border: 1px solid rgba(59, 130, 246, 0.2); }
.ext-docx { background: rgba(16, 185, 129, 0.15); color: rgb(52, 211, 153); border: 1px solid rgba(16, 185, 129, 0.2); }
.ext-xlsx { background: rgba(245, 158, 11, 0.15); color: rgb(251, 191, 36); border: 1px solid rgba(245, 158, 11, 0.2); }
.ext-zip, .ext-rar { background: rgba(139, 92, 246, 0.15); color: rgb(167, 139, 250); border: 1px solid rgba(139, 92, 246, 0.2); }
.ext-default { background: rgba(107, 114, 128, 0.15); color: rgb(156, 163, 175); border: 1px solid rgba(107, 114, 128, 0.2); }

.file-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-row:hover .file-title {
    color: var(--text-primary);
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 1rem;
    flex-shrink: 0;
}

.file-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
    flex-shrink: 0;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.btn-icon-open:hover {
    color: var(--accent-indigo);
    background: var(--accent-indigo-glow);
}

.btn-icon-view:hover {
    color: var(--accent-cyan);
    background: var(--accent-cyan-glow);
}

/* Modals & Setup Overlays */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 24, 0.75);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 650px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    animation: modal-enter var(--transition-normal);
}

@keyframes modal-enter {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

pre {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 10px;
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow-x: auto;
    max-height: 250px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    gap: 0.75rem;
}

/* Document Preview Panel */
.preview-pane-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 24, 0.6);
    z-index: 60;
    display: flex;
    justify-content: flex-end;
}

.preview-pane {
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    width: 60%;
    min-width: 600px;
    max-width: 900px;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
    animation: slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
    .preview-pane {
        width: 100%;
        min-width: 0;
    }
}

@keyframes slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.preview-header-title h3 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.preview-body {
    flex-grow: 1;
    position: relative;
    background: var(--bg-darker);
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff; /* White background matches typical PDF rendering */
}

/* Empty / Fallback states */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Notification Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-indigo);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    animation: toast-fade-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.toast-error {
    border-left-color: hsl(0, 80%, 60%);
}

.toast.toast-success {
    border-left-color: var(--accent-emerald);
}

@keyframes toast-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Simulated Scan Progress Modal styling */
.scan-progress-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 2rem 0;
}

.spinner-ring {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-emerald);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    animation: spin 0.8s linear infinite;
}

/* Responsive Footer */
footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-dark);
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto;
}

footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Selection Floating Action Bar */
.selection-bar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    width: calc(100% - 4rem);
    max-width: 750px;
    background: rgba(13, 20, 38, 0.85);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color-glow);
    border-radius: 16px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.45);
    animation: selection-bar-fade-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes selection-bar-fade-in {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.selection-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.5rem;
    gap: 1rem;
}

@media (max-width: 600px) {
    .selection-bar-content {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }
}

.selection-text {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.selection-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 600px) {
    .selection-actions {
        justify-content: space-between;
        margin-top: 0.5rem;
    }
}

.select-pole-dropdown {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.select-pole-dropdown:focus {
    border-color: var(--accent-indigo);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8rem;
}
