/* ==========================================
   VARIABLES & RESET
   ========================================== */
:root {
    --primary: #2C3E50;
    --secondary: #E74C3C;
    --accent: #3498DB;
    --success: #27AE60;
    --warning: #F39C12;
    --danger: #C0392B;
    --bg-light: #ECF0F1;
    --bg-dark: #34495E;
    --text-dark: #2C3E50;
    --text-light: #7F8C8D;
    --white: #FFFFFF;
    --border: #BDC3C7;
    
    --temp-cold: #3498DB;
    --temp-comfort: #27AE60;
    --temp-warm: #F39C12;
    --temp-hot: #E74C3C;
    
    --radius: 12px;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-dark);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* ==========================================
   LOGIN PAGE
   ========================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 30px;
    animation: fadeInUp 0.5s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-header p {
    font-size: 14px;
    color: var(--text-light);
}

.login-form {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-footer {
    text-align: center;
    font-size: 14px;
    color: var(--text-light);
}

.login-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--white);
}

.btn-primary:hover {
    background: #2980B9;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #229954;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================
   ALERTS
   ========================================== */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #FADBD8;
    color: var(--danger);
    border-left: 4px solid var(--danger);
}

.alert-success {
    background: #D5F4E6;
    color: var(--success);
    border-left: 4px solid var(--success);
}

/* ==========================================
   DASHBOARD LAYOUT
   ========================================== */
.dashboard-page {
    background: var(--bg-light);
    min-height: 100vh;
}

.main-header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.header-left h1 {
    font-size: 20px;
    color: var(--primary);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.customer-logo {
    max-height: 40px;
    max-width: 150px;
    object-fit: contain;
}

.header-right {
    display: flex;
    gap: 10px;
}

.btn-contact,
.btn-logout {
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.3s;
}

.btn-contact:hover,
.btn-logout:hover {
    background: var(--bg-light);
}

.icon-small {
    width: 24px;
    height: 24px;
}

/* Home Selector */
.home-selector {
    padding: 10px 20px;
    background: var(--bg-light);
    border-top: 1px solid var(--border);
}

.select-home {
    width: 100%;
    padding: 10px 15px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    cursor: pointer;
}

.select-home:focus {
    outline: none;
    border-color: var(--accent);
}

/* Actions Bar */
.actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--white);
    margin: 15px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.home-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.icon-btn {
    width: 20px;
    height: 20px;
}

/* ==========================================
   ROOMS GRID
   ========================================== */
.dashboard-container {
    padding: 0 20px 30px;
    max-width: 1400px;
    margin: 0 auto;
}

.rooms-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* Room Card */
.room-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.room-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.room-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-light);
}

.room-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.room-title {
    flex: 1;
}

.room-title h3 {
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 4px;
}

.room-title .room-subtitle {
    font-size: 13px;
    color: var(--text-light);
}

/* Room Info Grid */
.room-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
}

.info-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.info-content {
    flex: 1;
}

.info-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 2px;
}

.info-value {
    font-size: 18px;
    font-weight: 700;
}

/* Temperature Color Coding */
.temp-cold { color: var(--temp-cold); }
.temp-comfort { color: var(--temp-comfort); }
.temp-warm { color: var(--temp-warm); }
.temp-hot { color: var(--temp-hot); }

/* Battery Status */
.battery-low {
    color: var(--danger);
    animation: pulse 2s infinite;
}

.battery-medium {
    color: var(--warning);
}

.battery-good {
    color: var(--success);
}

/* Heater Status */
.heater-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.heater-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-light);
}

.heater-indicator.on {
    background: var(--secondary);
    animation: pulse 2s infinite;
}

.heater-indicator.off {
    background: var(--text-light);
}

/* Temperature Control */
.temp-control {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: var(--radius);
    color: var(--white);
}

.temp-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.temp-control-label {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.9;
}

.temp-control-value {
    font-size: 24px;
    font-weight: 700;
}

/* Slider */
.slider-container {
    margin-bottom: 15px;
}

.temp-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
    outline: none;
}

.temp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--white);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

.temp-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.temp-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    opacity: 0.8;
    margin-top: 5px;
}

/* ==========================================
   LOADING & TOAST
   ========================================== */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading p {
    color: var(--white);
    margin-top: 20px;
    font-size: 16px;
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 300px;
    max-width: 90%;
}

.toast {
    background: var(--white);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInUp 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);
}

.toast-icon {
    width: 24px;
    height: 24px;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-dark);
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


/* Ajustements pour petits écrans */
@media (max-width: 500px) {
    .home-timestamp {
        font-size: 12px;
    }
    
    .home-name {
        font-size: 14px;
    }
    
    .actions-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    #btn-refresh {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================
   RESPONSIVE - TABLETS
   ========================================== */
@media (min-width: 768px) {
    .rooms-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header-left h1 {
        font-size: 24px;
    }
    
    .customer-logo {
        max-height: 50px;
    }
}

/* ==========================================
   RESPONSIVE - DESKTOP
   ========================================== */
@media (min-width: 1024px) {
    .rooms-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .login-card {
        padding: 40px;
    }
	
	.customer-logo {
        max-height: 150px;
    }
}

@media (min-width: 1400px) {
    .rooms-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}