/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow: hidden;
    /* App-like feel */
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    transition: width 0.3s ease;
    overflow: hidden;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    color: var(--primary-color);
    /* Initial accent */
}

.logo span {
    color: white;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    flex: 1;
    overflow-y: auto;
    padding-bottom: var(--spacing-md);
}

.nav-item {
    text-decoration: none;
    color: #94a3b8;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all 0.2s;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    background-color: var(--bg-card);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-new {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-new:hover {
    background-color: var(--primary-hover);
}

.content-area {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--bg-card);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    /* Center vertically */
    gap: var(--spacing-md);
}

.stat-card .icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #e0e7ff;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .icon.warning {
    background-color: #fef3c7;
    color: var(--warning-color);
}

.stat-card .icon.info {
    background-color: #d1fae5;
    color: var(--accent-color);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-card .amount,
.stat-card .count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: visible;
    /* changed from hidden to allow dropdowns */
    box-shadow: var(--shadow-sm);
}

.data-table th,
.data-table td {
    padding: var(--spacing-sm);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
}

.data-table tr:hover {
    background-color: #f8fafc;
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-sm);
}

.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-top: 0.25rem;
}

.hidden {
    display: none !important;
}

/* Badges */
.badge {
    padding: 0.35em 0.65em;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-provisoire,
.badge-draft {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.badge-non-paye,
.badge-sent {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

/* Orange for Unpaid */
/* Orange for Unpaid/Sent */
.badge-paye,
.badge-paid,
.badge-success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.badge-info {
    background: #eff6ff;
    /* Blue-50 */
    color: #1d4ed8;
    /* Blue-700 */
    border: 1px solid #bfdbfe;
}

.badge-warning {
    background: #fffbeb;
    /* Amber-50 */
    color: #b45309;
    /* Amber-700 */
    border: 1px solid #fde68a;
}

.badge-danger {
    background: #fef2f2;
    /* Red-50 */
    color: #b91c1c;
    /* Red-700 */
    border: 1px solid #fecaca;
}

.badge-primary {
    background: #fdf4ff;
    /* Fuchsia-50 or Indigo */
    color: #86198f;
    /* Fuchsia-700 */
    border: 1px solid #f0abfc;
}

/* Filter Toolbar */
.filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
    background: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.search-container {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-container input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.search-container i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-primary {
    background-color: #0f172a;
    /* Dark button from screenshot */
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: #1e293b;
}

/* Settings View Styles */
.settings-header-section {
    margin-bottom: 2rem;
}

.settings-header-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.settings-header-section p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
}

.settings-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.settings-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-header-row h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-heading);
}

.card-header-row i {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.card-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
    line-height: 1.5;
}

.btn-settings {
    background-color: white;
    color: var(--text-heading);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    align-self: flex-start;
    transition: all 0.2s;
}

.btn-settings:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

/* Document Type Grid (Settings) */
.doc-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.doc-type-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    cursor: pointer;
    /* Hand cursor */
    transition: all 0.2s;
    font-weight: 500;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 60px;
}

.doc-type-card:hover {
    border-color: #94a3b8;
    /* Slate-400 */
    background: #f1f5f9;
    /* Slate-100 */
}

/* Specific styling for active state based on screenshot (dark bg) */
.doc-type-card.active {
    background-color: #0f172a;
    /* Slate-900 */
    color: white;
    border-color: #0f172a;
}

/* Data Management Styles */
.demo-banner {
    background-color: #fff7ed;
    /* Orange-50 */
    color: #9a3412;
    /* Orange-800 */
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #fed7aa;
    /* Orange-200 */
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.demo-banner span strong {
    color: #c2410c;
    /* Orange-700 */
}

.btn-upgrade {
    background-color: white;
    color: #ea580c;
    /* Orange-600 */
    border: 1px solid #fdba74;
    /* Orange-300 */
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-upgrade:hover {
    background-color: #ffedd5;
}

.notification-icon {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #22c55e;
    /* Green-500 from screenshot */
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Tabs for Data View */
.data-tabs {
    display: flex;
    background: #f1f5f9;
    /* Slate-100 */
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    /* Top rounded */
    gap: 1px;
    /* Gap for separator */
}

.data-tab-item {
    padding: 0.75rem 2rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.data-tab-item:hover {
    background: #e2e8f0;
    /* Slate-200 */
    color: var(--text-heading);
}

.data-tab-item.active {
    background: white;
    color: var(--primary-color);
    font-weight: 600;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.02);
}


.btn-action {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-heading);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-action:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.instructions-box {
    background-color: #f8fafc;
    /* Slate-50 */
    border: 1px solid #e2e8f0;
    /* Slate-200 */
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.nav-section-title {
    padding: 1.5rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
}

/* Collapsible nav groups */
.nav-group {
    border: none;
    margin: 0;
}
.nav-group summary {
    list-style: none;
}
.nav-group summary::-webkit-details-marker { display: none; }

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    margin: 0.1rem 0.5rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}
.nav-group-title:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary, #e2e8f0);
}
.nav-chevron {
    margin-left: auto;
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}
.nav-group[open] .nav-chevron {
    transform: rotate(180deg);
}
.nav-group-items {
    overflow: hidden;
    animation: slideDown 0.18s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.nav-group-items .nav-item {
    padding-left: 2.4rem;
    font-size: 0.88rem;
}
.nav-item-settings {
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding-top: 0.75rem !important;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: #0f172a;
}

input:focus+.slider {
    box-shadow: 0 0 1px #0f172a;
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Custom Searchable Select */
.custom-select-container {
    position: relative;
    width: 100%;
}

.select-selected {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    margin-top: 5px;
    overflow: hidden;
}

.select-search {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.select-search input {
    width: 100%;
    padding: 0.5rem 0.5rem 0.5rem 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
}

.select-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.select-items {
    max-height: 200px;
    overflow-y: auto;
}

.select-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.select-item:hover {
    background-color: #f8fafc;
}

.select-footer {
    border-top: 1px solid var(--border-color);
    padding: 0.5rem;
    background-color: #f8fafc;
}

.btn-add-new {
    width: 100%;
    padding: 0.5rem;
    background-color: white;
    /* Light bg as per screenshot? Or distinct? Screenshot shows light/button like */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-heading);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: block;
}

.btn-add-new:hover {
    background-color: #e2e8f0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: white;
    padding: 0;
    /* Reset padding, inner container will handle it */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Action Menu Dropdown */
.action-menu-container {
    position: relative;
    display: inline-block;
}

.action-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 5px;
    background-color: white;
    min-width: 220px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    /* Larger shadow for popover */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    z-index: 1000;
    /* Ensure it stays on top */
    padding: 0.5rem 0;
}

.action-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Confirm Modal */
#confirm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
#confirm-modal-overlay.show {
    opacity: 1;
}
.confirm-modal {
    background: var(--bg-card, #1e2330);
    border-radius: 12px;
    padding: 2rem 2rem 1.5rem;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
#confirm-modal-overlay.show .confirm-modal {
    transform: scale(1);
}
.confirm-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(239,68,68,0.15);
    color: #ef4444;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}
.confirm-modal-message {
    color: var(--text-primary, #e2e8f0);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}
.confirm-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.confirm-modal-actions .btn {
    min-width: 110px;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}
.confirm-modal-actions .btn:hover { opacity: 0.85; }
.confirm-modal-actions .btn-secondary {
    background: var(--bg-secondary, #2d3748);
    color: var(--text-secondary, #a0aec0);
    border: 1px solid var(--border-color, #4a5568);
}
.confirm-modal-actions .btn-danger {
    background: #ef4444;
    color: #fff;
}
.confirm-modal-actions .btn-warning {
    background: #f59e0b;
    color: #fff;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-notification.success {
    background-color: #10b981;
    /* Emerald-500 */
}

.toast-notification.error {
    background-color: #ef4444;
}

.toast-notification.info {
    background-color: #3b82f6;
}

.toast-notification i {
    font-size: 1.2rem;
}

.action-menu-header {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.25rem;
    background-color: #f8fafc;
}

.action-menu-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.action-menu-item:hover {
    background-color: #f1f5f9;
    color: var(--primary-color);
}

.action-menu-item i {
    width: 18px;
    text-align: center;
    color: var(--text-muted);
}

.action-menu-item:hover i {
    color: var(--primary-color);
}

/* Ensure table overflow allows dropdowns */
.data-table td {
    position: relative;
}