/* ==========================================
   VARIABLES GLOBALES
   ========================================== */
:root {
    /* Colores basados en tu logo miCasaDomoticaMx */
    --color-primary: #0077b6;
    /* Azul oscuro */
    --color-primary-dark: #03045e;
    --color-secondary: #00b4d8;
    /* Cian brillante */
    --color-accent: #f77f00;
    /* Naranja de "Mx" */
    --color-success: #06d6a0;
    --color-danger: #ef476f;

    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-text: #2b2d42;
    --color-text-muted: #8d99ae;
    --color-border: #edf2f4;

    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--color-text);
}

/* ==========================================
   CONTENEDOR DE AUTH (LOGIN/REGISTRO)
   ========================================== */
.auth-container {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 30px;
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: 10px;
}

.auth-logo .icon {
    font-size: 60px;
    display: block;
    margin-bottom: 10px;
}

.auth-title {
    text-align: center;
    font-size: 26px;
    color: var(--color-text);
    margin-bottom: 5px;
    font-weight: 700;
}

.auth-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 14px;
    margin-bottom: 30px;
}

/* ==========================================
   FORMULARIOS
   ========================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: var(--transition);
    background: #fafbfc;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.form-group input.error {
    border-color: var(--color-danger);
}

/* ==========================================
   BOTONES
   ========================================== */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.5);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    margin-top: 15px;
}

.btn-secondary:hover {
    background: rgba(33, 150, 243, 0.1);
}

/* ==========================================
   MENSAJES
   ========================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
}

.alert.show {
    display: block;
    animation: shake 0.3s ease;
}

.alert-error {
    background: #fee;
    color: var(--color-danger);
    border-left: 4px solid var(--color-danger);
}

.alert-success {
    background: #e8f5e9;
    color: var(--color-success);
    border-left: 4px solid var(--color-success);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* ==========================================
   LINK INFERIOR
   ========================================== */
.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.auth-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ==========================================
   SPINNER DE CARGA
   ========================================== */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
    display: none;
}

.spinner.show {
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 480px) {
    .auth-container {
        padding: 30px 20px;
        border-radius: var(--radius-md);
    }

    .auth-title {
        font-size: 22px;
    }

    .auth-logo .icon {
        font-size: 48px;
    }
}

/* ==========================================
   DASHBOARD STYLES
   ========================================== */
body.dashboard-body {
    display: block;
    /* Para que el dashboard no esté centrado como el login */
    background: var(--color-bg);
    padding: 0;
}

.navbar {
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .logo {
    height: 40px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-email {
    font-size: 14px;
    color: var(--color-text-muted);
    display: none;
    /* Oculto en móvil */
}

.btn-logout {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--color-danger);
    color: white;
}

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header {
    margin-bottom: 20px;
}

.dashboard-header h2 {
    color: var(--color-primary-dark);
    margin-bottom: 5px;
}

.dashboard-header p {
    color: var(--color-text-muted);
    font-size: 14px;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* ==========================================
   TARJETAS DE DISPOSITIVOS
   ========================================== */
.device-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
}

.device-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.device-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.device-status-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.device-status-badge.online {
    background: var(--color-success);
    color: white;
}

.device-body {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.capability-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}

.capability-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.capability-info {
    display: flex;
    flex-direction: column;
}

.capability-name {
    font-weight: 600;
    color: var(--color-text);
    font-size: 14px;
    text-transform: capitalize;
}

.capability-value {
    font-size: 18px;
    color: var(--color-primary-dark);
    font-weight: 700;
}

.capability-value.muted {
    color: var(--color-text-muted);
    font-size: 14px;
    font-weight: normal;
}

/* Switch (Interruptor) */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.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: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: var(--color-success);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

/* Botones de modo */
.mode-buttons {
    display: flex;
    gap: 5px;
    background: #e9ecef;
    padding: 3px;
    border-radius: var(--radius-sm);
}

.mode-btn {
    flex: 1;
    padding: 6px;
    border: none;
    background: transparent;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: var(--transition);
}

.mode-btn.active {
    background: white;
    color: var(--color-primary-dark);
    box-shadow: var(--shadow-sm);
}

/* Loading / Empty State */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--color-text-muted);
}

.empty-state .icon {
    font-size: 60px;
    margin-bottom: 15px;
    opacity: 0.5;
}

@media (min-width: 768px) {
    .user-email {
        display: block;
    }
}

/* ==========================================
   ESTILOS PARA EL LOGO
   ========================================== */
.auth-logo-img {
    display: block;
    max-width: 220px;
    /* Tamaño ideal para el login */
    height: auto;
    margin: 0 auto 20px auto;
}

.navbar .logo {
    height: 45px;
    /* Tamaño para la barra superior */
    width: auto;
}