/* ==========================================
   ThermoCare - Styles principaux
   ========================================== */

:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --primary-light: #f9e5e3;
    --secondary: #2c3e50;
    --secondary-light: #34495e;
    --accent: #e67e22;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --text-muted: #bdc3c7;
    --border: #dcdde1;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 5px 25px rgba(0,0,0,0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 260px;
    --topbar-height: 65px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================
   Sidebar
   ========================================== */
#sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--secondary) 0%, #1a252f 100%);
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

#sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 50%;
    background: white;
    padding: 5px;
    margin-bottom: 10px;
}

.sidebar-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
}

.nav-menu {
    list-style: none;
    padding: 15px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 25px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 4px solid transparent;
    gap: 14px;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    border-left-color: var(--primary);
}

.nav-item.active {
    background: rgba(231, 76, 60, 0.15);
    border-left-color: var(--primary);
    color: var(--primary);
}

.nav-item i {
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    gap: 8px;
}

.sidebar-footer button {
    flex: 1;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: transparent;
    color: #ecf0f1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.sidebar-footer button:hover {
    background: rgba(255,255,255,0.1);
}

/* ==========================================
   Main Content
   ========================================== */
#main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    min-height: 100vh;
}

#main-content.expanded {
    margin-left: 0;
}

#top-bar {
    height: var(--topbar-height);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    padding: 0 30px;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 50;
}

#top-bar h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--secondary);
}

.top-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
    padding: 5px;
}

.btn-icon:hover {
    color: var(--primary);
}

#page-content {
    padding: 25px 30px;
}

/* ==========================================
   Cards & Containers
   ========================================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-icon.red { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.stat-icon.blue { background: linear-gradient(135deg, var(--info), #2980b9); }
.stat-icon.green { background: linear-gradient(135deg, var(--success), #219a52); }
.stat-icon.orange { background: linear-gradient(135deg, var(--accent), #d35400); }
.stat-icon.purple { background: linear-gradient(135deg, #9b59b6, #8e44ad); }

.stat-info h4 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--secondary);
}

.stat-info p {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 2px;
}

/* ==========================================
   Grids
   ========================================== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: var(--secondary-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #e67e22; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--primary-dark); }
.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #2980b9; }
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: white;
}
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* ==========================================
   Forms
   ========================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: var(--transition);
    background: white;
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237f8c8d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

/* ==========================================
   Tables
   ========================================== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    background: var(--bg);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

table tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

table tbody tr:hover {
    background: var(--primary-light);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ==========================================
   Badges & Tags
   ========================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    gap: 5px;
}

.badge-gaz { background: #dbeafe; color: #1e40af; }
.badge-fioul { background: #fef3c7; color: #92400e; }
.badge-pellet { background: #d1fae5; color: #065f46; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #e5e7eb; color: #374151; }

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.badge-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.badge-status.active::before { background: var(--success); }
.badge-status.inactive::before { background: var(--text-muted); }
.badge-status.en-cours::before { background: var(--info); }
.badge-status.urgent::before { background: var(--danger); }

/* ==========================================
   Modal
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-container {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--secondary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    padding: 15px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ==========================================
   Toast
   ========================================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==========================================
   Calendar / Planning
   ========================================== */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-nav h3 {
    min-width: 200px;
    text-align: center;
    font-size: 1.1rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.calendar-day-header {
    background: var(--secondary);
    color: white;
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.calendar-day {
    background: white;
    min-height: 110px;
    padding: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.calendar-day:hover {
    background: var(--primary-light);
}

.calendar-day.today {
    background: #fef5f4;
    border: 2px solid var(--primary);
}

.calendar-day.other-month {
    opacity: 0.4;
}

.calendar-day .day-number {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: var(--secondary);
}

.calendar-day.today .day-number {
    color: var(--primary);
}

.calendar-event {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    margin-bottom: 3px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
}

.calendar-event.depannage { background: var(--danger); }
.calendar-event.entretien { background: var(--info); }
.calendar-event.installation { background: var(--success); }
.calendar-event.diagnostic { background: var(--accent); }

.calendar-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid var(--border);
    background: white;
    cursor: pointer;
    font-size: 0.82rem;
    transition: var(--transition);
}

.filter-chip.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* ==========================================
   Search & Toolbar
   ========================================== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.search-box {
    position: relative;
    min-width: 280px;
}

.search-box input {
    padding: 10px 14px 10px 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    width: 100%;
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ==========================================
   Empty state
   ========================================== */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-light);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 20px;
}

/* ==========================================
   Detail view
   ========================================== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detail-item {
    padding: 10px 0;
}

.detail-item .label {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-item .value {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ==========================================
   Planning - Vue semaine
   ========================================== */
.week-grid {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.week-time {
    background: var(--bg);
    padding: 8px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-light);
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.week-slot {
    background: white;
    min-height: 50px;
    padding: 4px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.week-slot:hover {
    background: var(--primary-light);
}

/* ==========================================
   Avatar
   ========================================== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 0.9rem;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-lg { width: 55px; height: 55px; font-size: 1.2rem; }

/* ==========================================
   Tabs
   ========================================== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ==========================================
   Info panel / Alerts
   ========================================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.mobile-open {
        transform: translateX(0);
    }
    #main-content {
        margin-left: 0;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .grid-3 { grid-template-columns: 1fr; }
    #page-content { padding: 15px; }
    .calendar-grid { font-size: 0.8rem; }
    .calendar-day { min-height: 70px; padding: 4px; }
}

/* ==========================================
   Print styles
   ========================================== */
@media print {
    #sidebar, #top-bar, .btn, .toolbar { display: none !important; }
    #main-content { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ==========================================
   Scrollbar
   ========================================== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ==========================================
   Animations
   ========================================== */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   Liste interventions planning
   ========================================== */
.intervention-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.intervention-list-item:last-child {
    border-bottom: none;
}

.intervention-time {
    font-weight: 600;
    color: var(--secondary);
    min-width: 55px;
    font-size: 0.85rem;
}

.intervention-info {
    flex: 1;
}

.intervention-info .title {
    font-weight: 500;
    margin-bottom: 3px;
}

.intervention-info .subtitle {
    font-size: 0.82rem;
    color: var(--text-light);
}

/* ==========================================
   Progress bar
   ========================================== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-bar .fill.green { background: var(--success); }
.progress-bar .fill.orange { background: var(--accent); }
.progress-bar .fill.red { background: var(--danger); }
.progress-bar .fill.blue { background: var(--info); }
