/* =====================================================
   CRM H&Y WAY - Styles CSS Responsive
   Charte graphique: #4DA6FF, #1F4E79, Montserrat/Roboto
===================================================== */

:root {
    --primary: #4DA6FF;
    --primary-dark: #1F4E79;
    --secondary: #1F4E79;
    --success: #27AE60;
    --warning: #F39C12;
    --danger: #E74C3C;
    --hot: #E74C3C;
    --warm: #F39C12;
    --cold: #3498DB;
    --bg-dark: #0a0a0a;
    --bg-card: #1a1a1a;
    --bg-input: #2a2a2a;
    --text: #ffffff;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border: #333;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
}

/* ========== LAYOUT ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

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

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}
.sidebar-close:hover { background: var(--bg-input); }
.sidebar-close svg { width: 24px; height: 24px; }

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo img { height: 40px; }

.logo span {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
}

.nav-menu {
    list-style: none;
    flex: 1;
}

.nav-item { margin-bottom: 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.3s;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(77, 166, 255, 0.1);
    color: var(--primary);
}

.nav-link svg { width: 20px; height: 20px; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.user-info {
    padding: 16px;
    background: var(--bg-input);
    border-radius: 12px;
    margin-bottom: 12px;
}
.user-name { font-weight: 600; }
.user-role { font-size: 0.85rem; color: var(--text-secondary); }

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    text-decoration: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all 0.2s;
}
.logout-btn:hover {
    background: var(--danger);
    color: white;
}

/* ========== MOBILE MENU BTN ========== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 999;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    color: var(--text);
}
.mobile-menu-btn svg { width: 24px; height: 24px; }

/* ========== SIDEBAR OVERLAY ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    min-width: 0;
}

/* ========== HEADER ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title {
    font-size: 1.8rem;
    color: var(--text-primary);
}

/* ========== CARDS ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.1rem;
    color: var(--text-primary);
}

/* ========== STATS CARDS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.hot::before { background: var(--hot); }
.stat-card.warm::before { background: var(--warm); }
.stat-card.cold::before { background: var(--cold); }
.stat-card.primary::before { background: var(--primary); }

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 8px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(77, 166, 255, 0.4);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.form-control::placeholder { color: var(--text-secondary); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 120px; resize: vertical; }

/* ========== TABLE ========== */
.table-container { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover { background: rgba(77, 166, 255, 0.05); }

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-hot { background: rgba(231, 76, 60, 0.2); color: var(--hot); }
.badge-warm { background: rgba(243, 156, 18, 0.2); color: var(--warm); }
.badge-cold { background: rgba(52, 152, 219, 0.2); color: var(--cold); }
.badge-status { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; }

/* ========== SCORE ========== */
.score-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.score-high { background: rgba(39, 174, 96, 0.2); color: var(--success); border: 2px solid var(--success); }
.score-medium { background: rgba(243, 156, 18, 0.2); color: var(--warning); border: 2px solid var(--warning); }
.score-low { background: rgba(231, 76, 60, 0.2); color: var(--danger); border: 2px solid var(--danger); }

/* ========== TIMELINE ========== */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-icon {
    position: absolute;
    left: -30px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-icon svg { width: 12px; height: 12px; color: white; }

.timeline-content {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 16px;
}

.timeline-date { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; }
.timeline-title { font-weight: 500; margin-bottom: 4px; }
.timeline-text { color: var(--text-secondary); font-size: 0.9rem; }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal { transform: scale(1); }

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

.modal-title { font-size: 1.2rem; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    font-size: 1.5rem;
}

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========== LOADING ========== */
.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== LOGIN PAGE ========== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo img { height: 60px; margin-bottom: 16px; }
.login-logo h1 { font-size: 1.5rem; color: var(--primary); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .mobile-menu-btn { display: block; }
    .sidebar-close { display: block; }
    
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open { transform: translateX(0); }
    
    .main-content {
        margin-left: 0;
        padding: 70px 16px 16px 16px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.8rem; }
    .stat-label { font-size: 0.8rem; }
    
    .page-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .page-title { font-size: 1.4rem; }
    
    .card { padding: 16px; }
}

@media (max-width: 480px) {
    .main-content { padding: 60px 12px 12px 12px; }
    
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 1.5rem; }
    
    .page-title { font-size: 1.2rem; }
    
    .btn { padding: 10px 16px; font-size: 0.85rem; }
    
    .modal { margin: 10px; }
    .modal-header, .modal-body, .modal-footer { padding: 16px; }
    
    .login-card { padding: 24px; }
}
