/* Style System Light & Minimalist - Syndic Copropriété */
:root {
    --bg-color: #f8fafc; /* Very light slate gray/blue */
    --primary-color: #0f172a; /* Deep Slate/Navy (buttons, headers) */
    --primary-hover: #1e293b;
    --accent-color: #0284c7; /* Sky blue accent */
    --text-main: #334155; /* Slate 700 for readable body text */
    --text-dark: #0f172a; /* Slate 900 for headings */
    --text-muted: #64748b; /* Slate 500 for secondary text */
    --card-bg: #ffffff; /* Pure white cards */
    --border-color: #e2e8f0; /* Light gray borders */
    --shadow-subtle: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background-color: var(--bg-color);
    font-family: var(--font-family);
    color: var(--text-main);
    font-size: 0.82rem; /* Small compact typography as requested */
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout Wrapper */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Mobile Header Bar (Only visible on mobile) */
.mobile-header {
    display: none;
    background-color: #0f172a;
    color: white;
    height: 50px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 101;
    border-bottom: 1px solid #1e293b;
    align-items: center;
    justify-content: space-between;
}

.menu-toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-brand {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.2px;
}

/* Sidebar Column Layout (Left side on desktop) */
.sidebar {
    width: 240px;
    background-color: #0f172a;
    color: white;
    border-right: 1px solid #1e293b;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand-wrapper {
    padding: 16px 20px;
    border-bottom: 1px solid #1e293b;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: white;
}

.brand-icon {
    font-size: 1.25rem;
}

.brand-name {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.2px;
}

.sidebar-user {
    padding: 14px 20px;
    border-bottom: 1px solid #1e293b;
    background-color: #090d16;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.badge-role {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-block;
    align-self: flex-start;
}

.badge-role.admin {
    background: rgba(244, 63, 94, 0.2);
    color: #fda4af;
    border: 1px solid rgba(244, 63, 94, 0.1);
}

.badge-role.copro {
    background: rgba(56, 189, 248, 0.15);
    color: #bae6fd;
    border: 1px solid rgba(56, 189, 248, 0.1);
}

/* Sidebar Nav Links */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 4px;
    margin: 2px 8px;
    transition: all 0.15s ease-in-out;
}

.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

.nav-divider {
    font-size: 0.68rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 16px 6px;
}

.nav-item-logout {
    color: #fda4af;
}

.nav-item-logout:hover {
    color: white;
    background-color: #ef4444;
}

/* Right Side: Content Area Wrap */
.main-content-wrapper {
    margin-left: 240px; /* Offset for fixed sidebar */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex children from stretching */
}

.main-container {
    flex: 1;
    padding: 24px 30px;
}

/* Responsive Sidebar rules for Mobile */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    
    .sidebar {
        top: 50px;
        left: -240px; /* Hidden offscreen */
        width: 240px;
        z-index: 100;
        transition: left 0.2s ease-in-out;
        border-right: 1px solid #1e293b;
        box-shadow: 10px 0 15px -3px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.open {
        left: 0; /* Slides in */
    }
    
    .main-content-wrapper {
        margin-left: 0; /* Take full width */
    }
    
    .main-container {
        padding: 20px 16px;
    }
}

/* Alert Banner */
.alert-banner {
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 20px;
}

.alert-banner.success {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.alert-banner.error {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Page Headers */
.page-header {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.page-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
}

.section-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* Dashboard Layout */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Cards (Clean Flat Design) */
.dash-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px 20px;
    box-shadow: var(--shadow-subtle);
}

.dash-card h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

/* Welcome Card */
.welcome-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.welcome-card h2 {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.welcome-card p {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.user-stats-bar {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.stat-badge-item {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.stat-badge-item .lbl {
    color: var(--text-muted);
}

.stat-badge-item .val {
    font-weight: 600;
    color: var(--text-dark);
}

.welcome-illustration {
    font-size: 2.5rem;
}

/* Lists (Pending / Recent items) */
.pending-list, .recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.pending-item, .recent-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: background 0.15s;
}

.pending-item:hover, .recent-item:hover {
    background: #f8fafc;
}

.pending-info, .recent-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.pending-title, .recent-title {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-dark);
}

.pending-meta, .recent-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.recent-icon {
    font-size: 1.1rem;
}

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

.empty-icon {
    font-size: 1.5rem;
    color: #10b981;
    display: block;
    margin-bottom: 6px;
}

/* Admin Actions and general buttons */
.admin-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 4px;
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
}

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

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

.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border-color: #cbd5e1;
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
}

.btn-full {
    width: 100%;
}

.btn-icon-only {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.text-center {
    text-align: center;
}

.flex-1 {
    flex: 1;
}

/* Dropzone (Upload) */
.upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 6px;
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.15s;
}

.upload-dropzone.dragover, .upload-dropzone:hover {
    border-color: var(--accent-color);
    background: #f0f9ff;
}

.upload-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.browse-link {
    color: var(--accent-color);
    font-weight: 600;
}

.file-limits {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Dynamic uploaded file row list */
.files-meta-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.file-meta-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 14px;
}

.file-card-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.file-ext {
    font-size: 0.7rem;
    font-weight: 700;
    background: #64748b;
    color: white;
    padding: 1px 4px;
    border-radius: 3px;
}

.file-name-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dark);
}

.file-card-inputs {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 12px;
}

@media (max-width: 768px) {
    .file-card-inputs {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

.input-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-item label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-item input, .input-item select {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 6px 10px;
    color: var(--text-dark);
    font-family: inherit;
    font-size: 0.8rem;
    outline: none;
}

.input-item input:focus, .input-item select:focus {
    border-color: var(--accent-color);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
}

.checkbox-group input {
    cursor: pointer;
}

.checkbox-group label {
    color: var(--text-dark);
    cursor: pointer;
    font-size: 0.75rem;
}

.checkbox-disabled {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

.flex-center {
    justify-content: center;
}

/* Category Grid / Filters */
.filter-bar {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-subtle);
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-group {
    flex: 1;
    min-width: 160px;
}

.search-group {
    flex: 1.5;
}

.filter-group input, .filter-group select {
    width: 100%;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--text-dark);
    outline: none;
    font-family: inherit;
    font-size: 0.8rem;
}

.filter-group input:focus, .filter-group select:focus {
    border-color: var(--accent-color);
}

/* Document Grid */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.document-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-subtle);
    transition: box-shadow 0.15s, transform 0.15s;
}

.document-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.document-ag-type {
    border-top: 3px solid var(--primary-color);
}

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

.doc-icon {
    font-size: 1.2rem;
}

.doc-year {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-dark);
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 3px;
}

.doc-card-body {
    flex: 1;
}

.doc-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
    line-height: 1.3;
}

.doc-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}

.doc-size-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.doc-card-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ag-signing-status {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
}

.status-labels .lbl {
    color: var(--text-muted);
}

.status-labels .val {
    font-weight: 700;
}

.status-labels .val.complete {
    color: #16803d;
}

.status-labels .val.in-progress {
    color: #d97706;
}

.status-bar-container {
    width: 100%;
    height: 4px;
    background: #f1f5f9;
    border-radius: 2px;
    overflow: hidden;
}

.status-bar {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 2px;
}

.doc-actions-row {
    display: flex;
    gap: 6px;
}

/* Signer Page (Split Column Layout) */
.main-content {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Status Cards & Lists */
.coowners-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.coowner-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
}

.status-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}

.status-badge.pending {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fde68a;
}

.status-badge.signed {
    background: #dcfce7;
    color: #16803d;
    border: 1px solid #bbf7d0;
}

/* Signature Canvas wrapper */
.signature-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.canvas-wrapper {
    position: relative;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
}

#signature-canvas {
    display: block;
    width: 100%;
    height: 160px;
    background: white;
    touch-action: none;
}

.canvas-hint {
    position: absolute;
    bottom: 5px;
    right: 8px;
    font-size: 0.62rem;
    color: #94a3b8;
    pointer-events: none;
    text-transform: uppercase;
}

/* Forms general */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group input {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 8px;
    color: var(--text-dark);
    font-size: 0.8rem;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent-color);
}

/* App Footer */
.app-footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 15px;
    text-align: center;
    margin-top: 40px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Empty State Large */
.empty-state-large {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-subtle);
}

.empty-icon-lg {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 10px;
}

.empty-state-large h3 {
    margin-bottom: 6px;
    font-size: 1rem;
    color: var(--text-dark);
}

/* Category CRUD Table design styled like reference screenshots */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover td {
    background-color: #f8fafc;
}

/* Inline Edit Input inside table cells */
.inline-edit-input {
    font-size: 0.8rem;
    padding: 3px 6px;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    width: 100%;
    outline: none;
    font-family: inherit;
    color: var(--text-dark);
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.1);
}

/* --- EXPLORATEUR INTERACTIF (FINDER / DRIVE) --- */

/* Modales popups */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
}

.modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    width: 90%;
    max-width: 400px;
    display: none;
    border: 1px solid var(--border-color);
}

.modal-card h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1rem;
    color: var(--text-dark);
}

/* Zone Drag & Drop overlay */
.explorer-wrapper {
    position: relative;
    min-height: 250px;
}

.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    border: 2px dashed var(--accent-color);
    border-radius: 8px;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Permet le drop */
    transition: all 0.2s ease;
}

.drag-overlay.active {
    display: flex;
}

.drag-overlay-content {
    text-align: center;
    color: var(--accent-color);
}

.drag-overlay-content strong {
    font-size: 1.25rem;
    display: block;
    margin-bottom: 4px;
}

/* Menu Contextuel Clic Droit */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 6px 0;
    z-index: 1000;
    display: none;
    min-width: 180px;
}

.context-item {
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-dark);
    display: block;
    transition: background 0.15s ease;
}

.context-item:hover {
    background: #f1f5f9;
    color: var(--accent-color);
}

.context-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Boîte Progression Drive */
.upload-progress-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    z-index: 2000;
    display: none;
    overflow: hidden;
}

.progress-box-header {
    background: var(--text-dark);
    color: white;
    padding: 12px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-box-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.progress-box-close:hover {
    color: white;
}

.progress-box-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 10px 16px;
}

.progress-row {
    margin-bottom: 12px;
}

.progress-row:last-child {
    margin-bottom: 0;
}

.progress-file-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    margin-bottom: 4px;
}

.progress-file-name {
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.progress-percentage {
    color: var(--text-muted);
}

.progress-bar-track {
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.1s linear;
}
