/**
 * AssurPro CRM SaaS - Styles principaux
 * Charte graphique : bleu marine professionnel
 * Framework : Bootstrap 5.3 avec surcharges custom
 */

/* === Variables CSS === */
:root {
    --ap-primary: #1B4F72;
    --ap-secondary: #2E86C1;
    --ap-accent: #17A589;
    --ap-danger: #E74C3C;
    --ap-warning: #F39C12;
    --ap-background: #F8F9FA;
    --ap-sidebar: #1B2631;
    --ap-sidebar-hover: #2C3E50;
    --ap-text: #2C3E50;
    --ap-text-muted: #7F8C8D;
    --ap-sidebar-width: 260px;
    --ap-sidebar-collapsed: 70px;
    --ap-header-height: 60px;
    --ap-transition: 0.3s ease;
}

/* === Reset et base === */
* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--ap-background);
    color: var(--ap-text);
    overflow-x: hidden;
}

a { color: var(--ap-secondary); text-decoration: none; }
a:hover { color: var(--ap-primary); }

/* === Surcharges Bootstrap === */
.btn-primary { background-color: var(--ap-primary); border-color: var(--ap-primary); }
.btn-primary:hover, .btn-primary:focus { background-color: #154360; border-color: #154360; }
.btn-secondary { background-color: var(--ap-secondary); border-color: var(--ap-secondary); }
.btn-success { background-color: var(--ap-accent); border-color: var(--ap-accent); }
.btn-success:hover { background-color: #138D75; border-color: #138D75; }
.btn-danger { background-color: var(--ap-danger); border-color: var(--ap-danger); }
.btn-warning { background-color: var(--ap-warning); border-color: var(--ap-warning); color: #fff; }
.btn-warning:hover { color: #fff; }
.bg-primary { background-color: var(--ap-primary) !important; }
.text-primary { color: var(--ap-primary) !important; }

.form-control:focus, .form-select:focus {
    border-color: var(--ap-secondary);
    box-shadow: 0 0 0 0.2rem rgba(46, 134, 193, 0.25);
}

.badge.bg-primary { background-color: var(--ap-primary) !important; }
.badge.bg-success { background-color: var(--ap-accent) !important; }

.page-link { color: var(--ap-primary); }
.page-item.active .page-link { background-color: var(--ap-primary); border-color: var(--ap-primary); }

/* === Sidebar === */
.sidebar {
    width: var(--ap-sidebar-width);
    min-height: 100vh;
    background: var(--ap-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width var(--ap-transition), transform var(--ap-transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-brand {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--ap-header-height);
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    color: #fff;
    text-decoration: none;
}

.sidebar-brand-icon {
    font-size: 28px;
    color: var(--ap-secondary);
    margin-right: 10px;
}

.sidebar-brand-text {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.sidebar-toggle { display: none; background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }

.sidebar-nav {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    flex: 1;
}

.sidebar-heading {
    padding: 12px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
}

.sidebar-item { margin: 1px 8px; }

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: rgba(255,255,255,0.65);
    border-radius: 8px;
    transition: all var(--ap-transition);
    font-size: 14px;
}

.sidebar-link i { font-size: 18px; width: 24px; margin-right: 10px; text-align: center; }

.sidebar-link:hover {
    color: #fff;
    background: var(--ap-sidebar-hover);
}

.sidebar-link.active {
    color: #fff;
    background: var(--ap-primary);
    font-weight: 500;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
}

.sidebar-user { display: flex; align-items: center; }

.sidebar-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--ap-secondary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    margin-right: 10px;
    flex-shrink: 0;
}

.sidebar-user-name { color: #fff; font-size: 13px; font-weight: 500; }
.sidebar-user-role { color: rgba(255,255,255,0.5); font-size: 11px; }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1030;
}

/* === Main Content === */
.main-content {
    margin-left: var(--ap-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--ap-transition);
}

/* === Header === */
.top-header {
    height: var(--ap-header-height);
    background: #fff;
    border-bottom: 1px solid #e5e8eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.header-left { display: flex; align-items: center; flex: 1; }
.header-right { display: flex; align-items: center; }

.header-search { max-width: 400px; width: 100%; }
.header-search .input-group { background: var(--ap-background); border-radius: 8px; }
.header-search .form-control { border: 1px solid #e5e8eb; font-size: 14px; padding: 8px 12px; border-radius: 0 8px 8px 0; }
.header-search .input-group-text { border: 1px solid #e5e8eb; border-right: none; border-radius: 8px 0 0 8px; }
.header-search .form-control:focus { border-color: var(--ap-secondary); }

.sidebar-toggler { padding: 0; margin-right: 10px; color: var(--ap-text); }

.notification-bell { color: var(--ap-text); padding: 5px; position: relative; }
.notification-bell:hover { color: var(--ap-primary); }
.notification-badge { font-size: 10px; }

.notification-dropdown { width: 360px; max-height: 400px; overflow-y: auto; padding: 0; }
.notification-header { border-bottom: 1px solid #eee; }
.notification-footer { border-top: 1px solid #eee; }
.notification-item { display: flex; padding: 10px 15px; border-bottom: 1px solid #f5f5f5; transition: background 0.2s; }
.notification-item:hover { background: #f8f9fa; }
.notification-item.unread { background: #f0f7ff; }
.notification-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; margin-right: 10px; flex-shrink: 0; }
.notification-icon i { font-size: 18px; }
.notification-title { font-size: 13px; font-weight: 500; color: var(--ap-text); }
.notification-text { font-size: 12px; color: var(--ap-text-muted); margin-top: 2px; }
.notification-time { font-size: 11px; color: #aaa; margin-top: 3px; }

.user-menu-btn { color: var(--ap-text); text-decoration: none; }
.user-menu-btn:hover { color: var(--ap-primary); }
.user-avatar-sm {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--ap-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 500; line-height: 1.2; }
.user-role { font-size: 11px; color: var(--ap-text-muted); }

/* === Content Area === */
.content-area { flex: 1; min-height: calc(100vh - var(--ap-header-height) - 50px); }

/* === Footer === */
.main-footer {
    padding: 12px 20px;
    border-top: 1px solid #e5e8eb;
    background: #fff;
}

/* === Cards KPI === */
.kpi-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.kpi-card .card-body { padding: 20px; }
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    color: #fff;
}
.kpi-value { font-size: 28px; font-weight: 700; color: var(--ap-text); line-height: 1.2; }
.kpi-label { font-size: 13px; color: var(--ap-text-muted); margin-top: 2px; }
.kpi-trend { font-size: 12px; margin-top: 5px; }
.kpi-trend.up { color: var(--ap-accent); }
.kpi-trend.down { color: var(--ap-danger); }

/* === Tables === */
.table-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.table-header h5 { margin: 0; font-weight: 600; color: var(--ap-text); }

.table-responsive { margin: 0; }

.data-table { margin-bottom: 0; }
.data-table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #e5e8eb;
    color: var(--ap-text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    white-space: nowrap;
}
.data-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}
.data-table tbody tr:hover { background: #f8f9fa; }
.data-table tbody tr:last-child td { border-bottom: none; }

.table-actions { white-space: nowrap; }
.table-actions .btn { padding: 4px 8px; font-size: 13px; }

.table-footer {
    padding: 12px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* === Forms === */
.form-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 24px;
}

.form-section { margin-bottom: 24px; }
.form-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ap-primary);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--ap-secondary);
    margin-bottom: 16px;
}

.form-label { font-weight: 500; font-size: 14px; color: var(--ap-text); margin-bottom: 4px; }
.form-label .required { color: var(--ap-danger); }

.invalid-feedback { font-size: 12px; }

/* === Auth Page === */
.auth-page {
    background: linear-gradient(135deg, var(--ap-primary) 0%, var(--ap-sidebar) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container { width: 100%; max-width: 420px; padding: 20px; }

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-logo {
    width: 70px; height: 70px;
    border-radius: 16px;
    background: var(--ap-primary);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
}

.auth-logo i { font-size: 36px; color: #fff; }
.auth-title { font-size: 24px; font-weight: 700; color: var(--ap-primary); }
.auth-subtitle { font-size: 14px; color: var(--ap-text-muted); margin-bottom: 24px; }

/* === Charts === */
.chart-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 20px;
}
.chart-container h5 { font-weight: 600; margin-bottom: 16px; color: var(--ap-text); }

/* === Badges & Labels === */
.badge { font-weight: 500; padding: 5px 10px; font-size: 12px; }

/* === Client Show page === */
.client-header {
    background: linear-gradient(135deg, var(--ap-primary), var(--ap-secondary));
    color: #fff;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.client-avatar {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    font-weight: 600;
}

.info-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 20px;
    height: 100%;
}

.info-card h6 {
    font-weight: 600;
    color: var(--ap-primary);
    border-bottom: 2px solid var(--ap-secondary);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.info-row { display: flex; padding: 6px 0; border-bottom: 1px solid #f5f5f5; }
.info-label { width: 140px; font-weight: 500; color: var(--ap-text-muted); font-size: 13px; flex-shrink: 0; }
.info-value { flex: 1; font-size: 14px; }

/* === Timeline === */
.timeline { position: relative; padding-left: 30px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0; bottom: 0;
    width: 2px;
    background: #e5e8eb;
}

.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--ap-secondary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--ap-secondary);
}

.timeline-content {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px 16px;
}

.timeline-date { font-size: 11px; color: var(--ap-text-muted); }
.timeline-text { font-size: 14px; margin-top: 4px; }

/* === Animations === */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp 0.3s ease-out; }

@keyframes countUp {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === Responsive === */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar-toggle { display: block; }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
    .header-search { max-width: 250px; }
}

@media (max-width: 767.98px) {
    .header-search { max-width: 180px; }
    .kpi-value { font-size: 22px; }
    .table-header { flex-direction: column; align-items: flex-start; }
    .content-area { padding: 12px !important; }
    .notification-dropdown { width: 300px; }
}

@media (max-width: 575.98px) {
    .auth-card { padding: 24px 20px; }
    .header-search { display: none; }
}

/* === Print === */
@media print {
    .sidebar, .top-header, .main-footer, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
}
