/* ==========================================
   ThermoCare Pro - Modules CSS additionnels
   ========================================== */

/* ==========================================
   LOGIN SCREEN
   ========================================== */
#login-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

#login-screen.hidden { display: none; }
#app.hidden { display: none !important; }

.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.login-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    animation: floatShape 15s infinite ease-in-out;
}

.shape-1 {
    width: 500px; height: 500px;
    background: #c41e3a;
    top: -100px; right: -100px;
    animation-delay: 0s;
}

.shape-2 {
    width: 300px; height: 300px;
    background: #e74c3c;
    bottom: -50px; left: -50px;
    animation-delay: 5s;
}

.shape-3 {
    width: 200px; height: 200px;
    background: #f39c12;
    top: 50%; left: 50%;
    animation-delay: 10s;
}

@keyframes floatShape {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 40px 35px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: contain;
    background: white;
    padding: 5px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 1.6rem;
    color: #1a1a2e;
    margin-bottom: 5px;
}

.login-header h1 span {
    color: #c41e3a;
    font-weight: 800;
}

.login-header p {
    color: #7f8c8d;
    font-size: 0.85rem;
}

.login-field {
    position: relative;
    margin-bottom: 18px;
}

.login-field i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    font-size: 0.9rem;
}

.login-field input {
    width: 100%;
    padding: 14px 45px 14px 45px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s;
    background: #f8f9fa;
}

.login-field input:focus {
    outline: none;
    border-color: #c41e3a;
    background: white;
    box-shadow: 0 0 0 4px rgba(196, 30, 58, 0.1);
}

.toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 5px;
}

.login-options {
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #c41e3a;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #c41e3a, #e74c3c);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(196, 30, 58, 0.35);
}

.login-error {
    margin-top: 15px;
    padding: 10px 15px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
}

.login-error.hidden { display: none; }

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.75rem;
    color: #999;
}

.login-footer a { color: #c41e3a; text-decoration: none; }

/* ==========================================
   SIDEBAR ENHANCED
   ========================================== */
.nav-section {
    padding: 18px 25px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    list-style: none;
}

.version-tag {
    font-size: 0.65rem;
    background: rgba(196, 30, 58, 0.3);
    color: #c41e3a;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.nav-badge {
    margin-left: auto;
    background: var(--info);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.nav-badge.urgent {
    background: var(--danger);
    animation: pulse 2s infinite;
}

.nav-badge:empty { display: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.user-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
}

.user-widget .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c41e3a, #e74c3c);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.user-info-sidebar {
    flex: 1;
    min-width: 0;
}

.user-info-sidebar .user-name {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info-sidebar .user-role {
    display: block;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
}

.user-widget button {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 5px;
    transition: color 0.3s;
}

.user-widget button:hover {
    color: #c41e3a;
}

/* ==========================================
   TOP BAR ENHANCED
   ========================================== */
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.global-search {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.global-search input {
    padding: 8px 60px 8px 35px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    width: 280px;
    transition: all 0.3s;
    background: var(--bg);
    font-family: inherit;
}

.global-search input:focus {
    outline: none;
    border-color: var(--primary);
    width: 350px;
    background: white;
}

.global-search kbd {
    position: absolute;
    right: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: inherit;
}

.notification-bell {
    position: relative;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.notification-bell:hover {
    background: var(--bg);
}

.notification-bell i {
    font-size: 1.1rem;
    color: var(--text-light);
}

.notif-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.notif-count:empty, .notif-count[data-count="0"] {
    display: none;
}

.current-date {
    font-size: 0.85rem;
    color: var(--text-light);
    white-space: nowrap;
}

/* ==========================================
   NOTIFICATION PANEL
   ========================================== */
.notif-panel {
    position: absolute;
    top: var(--topbar-height);
    right: 20px;
    width: 380px;
    max-height: 500px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
}

.notif-panel.hidden { display: none; }

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}

.notif-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.notif-list {
    max-height: 400px;
    overflow-y: auto;
}

.notif-item {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #fef5f4; }

.notif-item .notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: white;
}

.notif-item .notif-content {
    flex: 1;
    min-width: 0;
}

.notif-item .notif-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.notif-item .notif-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==========================================
   SEARCH RESULTS
   ========================================== */
.search-results {
    position: absolute;
    top: var(--topbar-height);
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    max-height: 400px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow-y: auto;
}

.search-results.hidden { display: none; }

.search-result-item {
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.search-result-item:hover { background: var(--primary-light); }

.search-result-item .result-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: var(--text-light);
}

.search-result-item .result-info { flex: 1; }
.search-result-item .result-title { font-weight: 500; font-size: 0.9rem; }
.search-result-item .result-sub { font-size: 0.78rem; color: var(--text-light); }
.search-result-item .result-type {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text-light);
    font-weight: 600;
}

.search-category {
    padding: 8px 18px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg);
    letter-spacing: 1px;
}

/* ==========================================
   CONTRATS MODULE
   ========================================== */
.contrat-card {
    border-left: 4px solid var(--info);
    padding: 18px;
    margin-bottom: 12px;
    background: white;
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.contrat-card:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-lg);
}

.contrat-card.expire { border-left-color: var(--danger); }
.contrat-card.bientot { border-left-color: var(--warning); }
.contrat-card.actif { border-left-color: var(--success); }

/* ==========================================
   STOCK MODULE
   ========================================== */
.stock-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.3s;
}

.stock-card:hover {
    box-shadow: var(--shadow-lg);
}

.stock-card .stock-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stock-card .stock-qty {
    font-size: 2rem;
    font-weight: 700;
    color: var(--secondary);
}

.stock-card .stock-qty.low { color: var(--danger); }
.stock-card .stock-qty.medium { color: var(--warning); }

.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

/* ==========================================
   CARTOGRAPHIE
   ========================================== */
.map-container {
    background: #e8e8e8;
    border-radius: var(--radius);
    height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.map-placeholder {
    text-align: center;
    color: var(--text-light);
}

.map-placeholder i {
    font-size: 4rem;
    margin-bottom: 15px;
    color: var(--text-muted);
}

/* ==========================================
   RAPPORTS
   ========================================== */
.report-card {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.report-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.report-card i {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.report-card h4 {
    margin-bottom: 5px;
}

.report-card p {
    font-size: 0.82rem;
    color: var(--text-light);
}

.chart-container {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.chart-bar .label {
    width: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    text-align: right;
}

.chart-bar .bar-bg {
    flex: 1;
    height: 28px;
    background: var(--bg);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.chart-bar .bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s ease;
    display: flex;
    align-items: center;
    padding-left: 10px;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.chart-bar .value {
    width: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

/* ==========================================
   PARAMÈTRES
   ========================================== */
.settings-section {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.settings-section-header {
    padding: 18px 22px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-section-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.settings-section-header i {
    color: var(--primary);
}

.settings-section-body {
    padding: 20px 22px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-row .setting-info h4 {
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.setting-row .setting-info p {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    left: 3px;
    bottom: 3px;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* ==========================================
   DRAG & DROP INTERVENTION
   ========================================== */
.draggable {
    cursor: grab;
}

.draggable:active {
    cursor: grabbing;
}

.drag-over {
    background: var(--primary-light) !important;
    border: 2px dashed var(--primary) !important;
}

/* ==========================================
   TIMELINE
   ========================================== */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
    padding-left: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item.completed::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-item.warning::before { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }

.timeline-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.timeline-content {
    background: white;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

/* ==========================================
   QUICK ACTIONS
   ========================================== */
.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 22px;
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    min-width: 120px;
}

.quick-action-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
}

.quick-action-btn i {
    font-size: 1.5rem;
    color: var(--primary);
}

.quick-action-btn span {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--secondary);
}

/* ==========================================
   KPI WIDGET
   ========================================== */
.kpi-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.kpi-widget {
    flex: 1;
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
}

.kpi-widget .kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--secondary);
    line-height: 1;
}

.kpi-widget .kpi-label {
    font-size: 0.78rem;
    color: var(--text-light);
}

.kpi-widget .kpi-trend {
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}

.kpi-widget .kpi-trend.up { color: var(--success); }
.kpi-widget .kpi-trend.down { color: var(--danger); }

/* ==========================================
   RESPONSIVE mobile fixes
   ========================================== */
@media (max-width: 768px) {
    .global-search { display: none; }
    .current-date { display: none; }
    .top-bar-right { gap: 8px; }
    .notif-panel { width: 100%; right: 0; }
    .search-results { width: 100%; left: 0; transform: none; }
    .kpi-row { flex-direction: column; }
    .quick-actions { justify-content: center; }
}

@media (max-width: 480px) {
    .login-card { padding: 30px 20px; }
    .login-logo { width: 60px; height: 60px; }
}

/* ==========================================
   CHART BAR ROWS (Rapports / Cartographie)
   ========================================== */
.chart-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.chart-bar-row .chart-label {
    min-width: 90px;
    font-size: 0.82rem;
    font-weight: 500;
    text-align: right;
    color: var(--text-light);
}

.chart-bar-row .chart-bar-bg {
    flex: 1;
    height: 24px;
    background: var(--bg);
    border-radius: 6px;
    overflow: hidden;
}

.chart-bar-row .chart-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.chart-bar-row .chart-value {
    min-width: 36px;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: right;
    color: var(--secondary);
}

/* ==========================================
   DETAIL GRIDS (Contrats / Stock views)
   ========================================== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-grid .full-width {
    grid-column: 1 / -1;
}

.detail-section {
    padding: 0;
}

.detail-section h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-section h4 i {
    color: var(--primary);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.detail-row span:first-child {
    color: var(--text-muted);
}

.detail-row span:last-child,
.detail-row strong {
    color: var(--secondary);
}

.detail-section p {
    font-size: 0.88rem;
    color: var(--text);
    line-height: 1.6;
}

/* ==========================================
   TIMELINE MOBILE (Cartographie tournée)
   ========================================== */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline .timeline-item {
    position: relative;
    padding-left: 20px;
    margin-bottom: 16px;
}

.timeline .timeline-marker {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.timeline .timeline-content {
    background: var(--bg);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ==========================================
   TABLE UTILITIES
   ========================================== */
.row-warning {
    background: #fffbeb !important;
}

.text-danger {
    color: var(--danger) !important;
    font-weight: 700;
}

code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'SF Mono', 'Consolas', monospace;
    color: var(--primary);
}

/* ==========================================
   SETTINGS LAYOUT
   ========================================== */
.settings-layout {
    max-width: 900px;
}

.settings-toggles {
    padding: 16px;
}

.setting-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.setting-toggle:last-child {
    border-bottom: none;
}

/* map pins animation */
.map-pin {
    transition: transform 0.2s;
}
.map-pin:hover {
    transform: translate(-50%, -100%) scale(1.15) !important;
    z-index: 10;
}

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .settings-layout {
        max-width: 100%;
    }
}
