/**
 * TECH Menuiserie Finance - Layout & Module Styles
 * Extends variables.css + components.css
 */

/* ===== LOGIN ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-alt);
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: var(--space-10);
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: var(--space-8);
}
.login-sigla {
    margin-bottom: var(--space-3);
    filter: drop-shadow(0 2px 8px rgba(0, 49, 104, 0.15));
}
.login-logo .logo-tech {
    font-family: var(--font-heading);
    font-size: var(--text-4xl);
    color: var(--primary);
}
.login-logo .logo-tagline {
    font-size: var(--text-sm);
    color: var(--text-muted);
}
.login-error {
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    color: #991b1b;
    background: var(--error-light);
    border-radius: var(--radius);
}

/* ===== SHELL ===== */
.finance-shell { min-height: 100vh; background: var(--bg-alt); }

/* ===== HEADER ===== */
.fin-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--space-6);
    background: var(--primary);
    color: white;
}
.fin-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}
.fin-header-left .logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}
.logo-sigla {
    filter: brightness(0) invert(1);
    opacity: 0.95;
    transition: opacity var(--transition);
}
.fin-header-left .logo:hover .logo-sigla { opacity: 1; }
.fin-header-left .logo-tech {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    color: white;
}
.fin-header-left .logo-tagline {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.7);
}
.fin-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}
.fin-header-right .btn-icon {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: white;
}
.fin-header-right .btn-icon:hover { background: rgba(255,255,255,0.2); }
.header-link {
    color: rgba(255,255,255,0.7);
    padding: var(--space-2);
    border-radius: var(--radius);
    transition: all var(--transition);
    display: flex;
}
.header-link:hover { color: white; background: rgba(255,255,255,0.1); }
.header-user { display: flex; align-items: center; gap: var(--space-2); }
.user-name { font-size: var(--text-sm); font-weight: 500; }
.user-role { font-size: 10px; padding: 2px 8px; background: rgba(255,255,255,0.15); color: white; }

/* Hamburger */
.hamburger {
    display: none;
    flex-direction: column;
    gap: var(--space-1);
    width: 36px; height: 36px;
    padding: var(--space-2);
    background: none; border: none;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background var(--transition);
}
.hamburger:hover { background: rgba(255,255,255,0.1); }
.hamburger span { display: block; height: 2px; background: white; border-radius: 2px; }

/* ===== SIDEBAR ===== */
.fin-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: var(--z-dropdown);
    transition: width var(--transition-slow), transform var(--transition-slow);
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: var(--space-4) var(--space-3);
    gap: var(--space-1);
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--radius);
    transition: all var(--transition);
    text-decoration: none;
}
.sidebar-link:hover { color: var(--primary); background: var(--bg-alt); }
.sidebar-link.active {
    color: var(--primary);
    background: rgba(0, 49, 104, 0.06);
    font-weight: 600;
    border-left: 3px solid var(--accent);
    padding-left: calc(var(--space-4) - 3px);
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.5; transition: opacity var(--transition); }
.sidebar-link:hover svg { opacity: 0.8; }
.sidebar-link.active svg { opacity: 1; }

/* ===== MAIN CONTENT ===== */
.fin-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: var(--space-6);
    min-height: calc(100vh - var(--header-height));
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}
.page-header h2 { font-size: var(--text-2xl); margin: 0; }
.page-header-actions { display: flex; gap: var(--space-3); align-items: center; }

/* ===== SUMMARY CARDS ===== */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.summary-card {
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.summary-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.summary-card-value {
    font-family: var(--font-mono);
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--primary);
    margin-bottom: var(--space-1);
}
.summary-card-label { font-size: var(--text-sm); color: var(--text-muted); }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
    align-items: center;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 160px; }
.filter-chip {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 500;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition);
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== MODAL ===== */
.modal-backdrop {
    position: fixed; inset: 0; z-index: var(--z-modal);
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.4); animation: fade-in 0.2s ease;
}
.modal-content {
    background: var(--bg); border-radius: var(--radius-lg); padding: var(--space-8);
    max-width: 600px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-xl);
}
.modal-content h3 { margin-bottom: var(--space-4); }
.modal-actions { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-6); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ===== TVA SUMMARY ===== */
.tva-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.tva-box {
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: var(--space-6);
    border: 1px solid var(--border);
}
.tva-box h4 { font-size: var(--text-base); margin-bottom: var(--space-4); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.tva-row { display: flex; justify-content: space-between; padding: var(--space-2) 0; font-size: var(--text-sm); }
.tva-row.total { font-weight: 600; border-top: 2px solid var(--border); padding-top: var(--space-3); margin-top: var(--space-2); }

/* ===== FEC EXPORT ===== */
.fec-card {
    max-width: 500px;
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: var(--space-8);
    border: 1px solid var(--border);
    text-align: center;
}
.fec-card svg { margin-bottom: var(--space-4); color: var(--primary); }
.fec-card p { color: var(--text-muted); font-size: var(--text-sm); }

/* ===== MARGINS ===== */
.margin-positive { color: var(--success); }
.margin-negative { color: var(--error); }
.margin-bar { height: 8px; background: var(--bg-alt); border-radius: var(--radius-full); overflow: hidden; }
.margin-bar-fill { height: 100%; border-radius: var(--radius-full); transition: width var(--transition-slow); }

/* ===== TOASTS ===== */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + var(--space-4));
    right: var(--space-4);
    z-index: var(--z-tooltip);
    display: flex; flex-direction: column; gap: var(--space-2);
}
.toast {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    background: var(--bg); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); border-left: 4px solid var(--info);
    font-size: var(--text-sm); animation: toast-in 0.3s ease; max-width: 400px;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--error); }
.toast.removing { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(100px); } }

/* ===== MISSING CLASSES (used by JS views) ===== */
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary); color: white; }

.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--bg-alt); }

/* Invoice status badges */
.badge-draft { background: #f3f4f6; color: var(--text-muted); }
.badge-issued { background: var(--info-light); color: #1e40af; }
.badge-paid { background: var(--success-light); color: #065f46; }
.badge-overdue { background: var(--error-light); color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: var(--text-light); text-decoration: line-through; }
.badge-credited { background: var(--accent-light); color: var(--accent-hover); }

/* Supplier type badges */
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* Utility classes */
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1024px) {
    .fin-sidebar { width: var(--sidebar-collapsed); }
    .sidebar-link span { display: none; }
    .sidebar-link { justify-content: center; padding: var(--space-3); }
    .fin-content { margin-left: var(--sidebar-collapsed); }
}
@media (max-width: 768px) {
    .hamburger { display: flex; }
    .fin-sidebar { width: var(--sidebar-width); transform: translateX(-100%); }
    .fin-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
    .sidebar-link span { display: inline; }
    .fin-content { margin-left: 0; padding: var(--space-4); }
    .summary-grid { grid-template-columns: 1fr; }
    .tva-breakdown { grid-template-columns: 1fr; }
    .header-user .user-name { display: none; }
}
