/* ============================================
   SMART HOME - CSS STYLING
   ============================================ */

:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* ============ NAVBAR ============ */
.navbar {
    background: var(--dark-color);
    color: var(--white);
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-logo i {
    color: var(--primary-color);
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 1rem;
}

.nav-item {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
}

.nav-item.active {
    background: var(--primary-color);
    color: var(--white);
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger-color);
    animation: pulse 1.5s infinite;
}

.status-indicator.online {
    background: var(--secondary-color);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-top: 80px;
    padding: 2rem;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-title {
    color: var(--white);
    margin-bottom: 2rem;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

/* ============ DASHBOARD ============ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.card-header i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.card-body {
    text-align: center;
}

/* ============ DOOR STATUS ============ */
.door-status {
    padding: 2rem;
    margin-bottom: 1rem;
}

.door-status i {
    font-size: 3rem;
    color: var(--danger-color);
}

.door-status span {
    display: block;
    margin-top: 0.5rem;
    font-size: 1.2rem;
    color: var(--dark-color);
}

.door-status.unlocked i {
    color: var(--secondary-color);
}

/* ============ BUTTONS ============ */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--white);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: var(--secondary-color);
}

.btn-success:hover {
    background: #27ae60;
}

.btn-danger {
    background: var(--danger-color);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: var(--dark-color);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.2rem;
}

/* ============ RELAY GRID ============ */
.relay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.relay-card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
    transition: var(--transition);
}

.relay-card.active {
    background: #d4edda;
    border: 2px solid var(--secondary-color);
}

.relay-icon {
    font-size: 3rem;
    color: var(--dark-color);
    margin-bottom: 1rem;
}

.relay-card.active .relay-icon {
    color: var(--secondary-color);
}

.relay-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.relay-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--secondary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* ============ DOOR CONTROLS ============ */
.door-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.door-card {
    text-align: center;
    padding: 3rem;
}

.door-animation {
    margin-bottom: 2rem;
}

.door-icon {
    font-size: 5rem;
    color: var(--dark-color);
    animation: doorPulse 2s infinite;
}

@keyframes doorPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.door-state-text {
    font-size: 1.5rem;
    margin-top: 1rem;
    color: var(--dark-color);
}

.door-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ============ RFID LIST ============ */
.rfid-card {
    padding: 2rem;
}

.rfid-list {
    margin: 1rem 0;
    max-height: 400px;
    overflow-y: auto;
}

.rfid-item {
    background: var(--light-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.rfid-item:hover {
    background: #d5dbdb;
}

.rfid-remove {
    color: var(--danger-color);
    cursor: pointer;
    transition: var(--transition);
}

.rfid-remove:hover {
    transform: scale(1.2);
}

.rfid-add {
    display: flex;
    gap: 1rem;
}

.rfid-add input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

/* ============ SENSOR ============ */
.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-card {
    padding: 1.5rem;
}

.chart-card canvas {
    width: 100% !important;
    height: 300px !important;
}

.sensor-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.sensor-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.sensor-item i {
    font-size: 2rem;
    color: var(--primary-color);
}

.sensor-info span {
    color: #7f8c8d;
    font-size: 0.875rem;
}

.sensor-info h3 {
    color: var(--dark-color);
    font-size: 1.5rem;
}

/* ============ MODAL ============ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .nav-menu {
        flex-direction: column;
        display: none;
    }
    
    .nav-menu.show {
        display: flex;
    }
    
    .dashboard-grid,
    .door-container,
    .sensor-grid {
        grid-template-columns: 1fr;
    }
    
    .door-controls {
        flex-direction: column;
    }
    
    .relay-grid {
        grid-template-columns: 1fr;
    }
}