/* ====================================================
   ÓPTICAPRO ADMIN - TEMA iCLOUD GLASSMORPHISM
==================================================== */
:root { 
    --primary: #0ea5e9; --secondary: #0284c7; --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    /* ☀️ LIGHT MODE */
    --bg-overlay: rgba(248, 250, 252, 0.3); --glass-bg: rgba(255, 255, 255, 0.75); 
    --glass-border: rgba(255, 255, 255, 0.8); --text-main: #0f172a; --text-muted: #475569;
    --widget-bg: rgba(255, 255, 255, 0.5); --widget-hover: rgba(255, 255, 255, 0.8);
    --input-bg: rgba(255, 255, 255, 0.7); --modal-bg: rgba(255, 255, 255, 0.85);
    --table-header: rgba(0, 0, 0, 0.05); --table-border: rgba(0, 0, 0, 0.08);
    --table-hover-bg: rgba(0, 0, 0, 0.02); --btn-cancel-bg: rgba(0, 0, 0, 0.05);
    --btn-cancel-text: #475569; --chat-bg: rgba(255, 255, 255, 0.5);
    --msg-in-bg: rgba(255, 255, 255, 0.9); --msg-in-text: #1e293b;
}

[data-theme="dark"] {
    /* 🌙 DARK MODE */
    --bg-overlay: rgba(0, 0, 0, 0.5); --glass-bg: rgba(15, 23, 42, 0.65); 
    --glass-border: rgba(255, 255, 255, 0.15); --text-main: #ffffff; --text-muted: #cbd5e1;
    --widget-bg: rgba(255, 255, 255, 0.05); --widget-hover: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(0, 0, 0, 0.3); --modal-bg: rgba(15, 23, 42, 0.85);
    --table-header: rgba(255, 255, 255, 0.1); --table-border: rgba(255, 255, 255, 0.05);
    --table-hover-bg: rgba(255, 255, 255, 0.03); --btn-cancel-bg: rgba(255, 255, 255, 0.1);
    --btn-cancel-text: #ffffff; --chat-bg: rgba(0, 0, 0, 0.3);
    --msg-in-bg: rgba(255, 255, 255, 0.1); --msg-in-text: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

body { 
    background-image: linear-gradient(var(--bg-overlay), var(--bg-overlay)), url('https://opticapro.xyz/fondos/wallpaper.jpg');
    background-position: center center; background-repeat: no-repeat; background-attachment: fixed; background-size: cover;
    background-color: #0f172a; color: var(--text-main); line-height: 1.6; min-height: 100vh;
    transition: color 0.3s ease, background 0.3s ease;
}

/* HEADER & ESTRUCTURA BASE */
.dash-header { padding: 1.5rem 3rem; display: flex; justify-content: space-between; align-items: center; }
.dash-header .logo { font-weight: 700; font-size: 1.5rem; letter-spacing: -0.5px; }
.dash-user { display: flex; align-items: center; gap: 1rem; font-size: 1rem; font-weight: 500; }
.btn-logout, .btn-theme { background: var(--widget-bg); border: 1px solid var(--glass-border); color: var(--text-main); padding: 0.5rem 1.2rem; border-radius: 20px; cursor: pointer; transition: var(--transition); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; }
.btn-logout:hover { background: #ef4444; border-color: #ef4444; color: white; }
.btn-theme { padding: 0.5rem; width: 40px; height: 40px; font-size: 1.2rem; border-radius: 50%; }
.btn-theme:hover { background: var(--widget-hover); }

.dash-container { display: flex; flex: 1; max-width: 1600px; margin: 0 auto; width: 100%; padding: 0 2rem 2rem 2rem; gap: 2rem; }

/* SIDEBAR ADMIN */
.sidebar { width: 280px; height: fit-content; flex-shrink: 0; background: var(--glass-bg); backdrop-filter: blur(20px); border-radius: 24px; border: 1px solid var(--glass-border); overflow: hidden; padding-bottom: 1rem; transition: var(--transition); }
.sidebar .section-title { padding: 1.5rem 1.5rem 0.5rem 1.5rem; font-size: 0.75rem; text-transform: uppercase; font-weight: 700; color: var(--text-muted); letter-spacing: 1px; }
.sidebar a { display: flex; align-items: center; padding: 0.8rem 1.5rem; color: var(--text-main); font-weight: 500; text-decoration: none; transition: var(--transition); margin: 0 0.8rem; border-radius: 12px; }
.sidebar a:hover { background: var(--widget-bg); }
.sidebar a.active { background: var(--primary); color: white; font-weight: 600; box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);}

/* 🚨 NUEVO: GLOBOS DE NOTIFICACIÓN CHAT ROJOS */
.chat-badge {
    background: #ef4444; color: white; border-radius: 50%;
    padding: 2px 7px; font-size: 0.75rem; font-weight: bold;
    margin-left: auto; display: inline-block; box-shadow: 0 2px 5px rgba(239,68,68,0.4);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-badge.hidden { display: none !important; }
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }

/* PANELES */
.main-content { flex: 1; min-width: 0; }
.panel { background: var(--glass-bg); backdrop-filter: blur(20px); border-radius: 24px; border: 1px solid var(--glass-border); padding: 2.5rem; display: none; animation: fadeIn 0.4s ease; transition: var(--transition); }
.panel.active { display: block; }
.panel h2 { margin-bottom: 1.5rem; color: var(--text-main); font-weight: 600; font-size: 1.8rem; }
.icloud-widget { background: var(--widget-bg); border: 1px solid var(--glass-border); border-radius: 20px; padding: 1.5rem; transition: var(--transition); }

/* TABLAS Y BADGES */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.95rem; min-width: 600px; }
th, td { text-align: left; padding: 1.2rem 1rem; border-bottom: 1px solid var(--table-border); }
th { color: var(--text-muted); font-weight: 600; background: var(--table-header); }
tr:hover td { background: var(--table-hover-bg); }
.badge { padding: 0.3rem 0.6rem; border-radius: 50px; font-size: 0.8rem; font-weight: bold;}
.badge.active { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.4);}
.badge.inactive { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.4);}
.badge.warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.4);}

/* BOTONES ADMIN */
.btn-action { background: var(--widget-bg); border: 1px solid var(--glass-border); padding: 0.6rem 1.2rem; border-radius: 12px; color: var(--text-main); cursor: pointer; font-weight: 600; transition: var(--transition); backdrop-filter: blur(5px); }
.btn-action:hover { background: var(--widget-hover); }
.btn-danger { color: #ef4444; border-color: rgba(239, 68, 68, 0.5); }
.btn-danger:hover { background: #ef4444; color: white; }
.btn-filter { background: var(--widget-bg); border: 1px solid var(--glass-border); padding: 0.5rem 1.2rem; border-radius: 20px; cursor: pointer; font-weight: 600; color: var(--text-muted); transition: all 0.2s; }
.btn-filter.active { background: var(--primary); color: white; border-color: var(--primary); }

/* MODALES APPLE */
.apple-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 9999; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.apple-modal-overlay.active { opacity: 1; visibility: visible; }
.apple-modal { background: var(--modal-bg); border: 1px solid var(--glass-border); border-radius: 24px; padding: 30px 24px; width: 90%; max-width: 400px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3); transform: scale(0.95) translateY(10px); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); text-align: center; color: var(--text-main); }
.apple-modal-overlay.active .apple-modal { transform: scale(1) translateY(0); }
.apple-modal-icon { width: 60px; height: 60px; background: var(--widget-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; margin: 0 auto 15px auto; }
.apple-modal h3 { margin: 0 0 10px 0; font-size: 1.3rem; font-weight: 700; }
.apple-modal p { margin: 0 0 20px 0; color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; }
.apple-input, .apple-select { width: 100%; padding: 12px 15px; background: var(--input-bg); border: 1px solid var(--glass-border); border-radius: 12px; font-size: 1rem; color: var(--text-main); outline: none; margin-bottom: 15px; text-align: center; }
.apple-select { text-align: left; }
.apple-select option { background: var(--modal-bg); color: var(--text-main); }
.apple-input:focus, .apple-select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.2); }
.apple-actions { display: flex; gap: 10px; margin-top: 10px; }
.apple-btn { flex: 1; padding: 12px 5px; border-radius: 12px; font-size: 0.95rem; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; }
.apple-btn-cancel { background: var(--btn-cancel-bg); color: var(--btn-cancel-text); border: 1px solid var(--glass-border);}
.apple-btn-cancel:hover { background: var(--widget-hover); }
.apple-btn-confirm { background: var(--primary); color: white; }
.apple-btn-confirm:hover { background: #0284c7; }
.apple-btn-danger { background: #ef4444; color: white; }

/* CHAT ADMIN LAYOUT */
.chat-layout { display: flex; height: 500px; border-radius: 16px; overflow: hidden; background: transparent; }
.chat-contacts { width: 250px; background: var(--table-header); border-right: 1px solid var(--glass-border); overflow-y: auto; display: flex; flex-direction: column; }
.chat-contact { padding: 1rem; border-bottom: 1px solid var(--glass-border); cursor: pointer; transition: var(--transition); }
.chat-contact:hover { background: var(--widget-hover); }
.chat-contact.active { background: rgba(14, 165, 233, 0.1); border-left: 4px solid var(--primary); }
.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-header-main { padding: 1rem 1.5rem; border-bottom: 1px solid var(--glass-border); font-weight: bold; display: flex; justify-content: space-between; align-items: center; background: var(--table-header);}
.chat-online-dot { display:inline-block; width: 10px; height: 10px; background-color: #10b981; border-radius: 50%; margin-right: 8px;}
.chat-body-main { flex: 1; padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.msg-bubble { max-width: 75%; padding: 12px 16px; border-radius: 15px; font-size: 0.95rem; line-height: 1.4; }
.msg-in { background: var(--msg-in-bg); color: var(--msg-in-text); align-self: flex-start; border-bottom-left-radius: 2px; border: 1px solid var(--glass-border); }
.msg-out { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.chat-input-main { display: flex; padding: 1rem 1.5rem; background: var(--table-header); border-top: 1px solid var(--glass-border); gap: 15px; }
.chat-input-main input { flex: 1; background: var(--input-bg); border: 1px solid var(--glass-border); color: var(--text-main); padding: 0.9rem 1.5rem; border-radius: 50px; outline: none; }
.chat-input-main button { background: var(--primary); color: white; border: none; width: 45px; height: 45px; border-radius: 50%; cursor: pointer; }

/* TOAST NOTIFICACIONES */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 99999; display: flex; flex-direction: column; gap: 12px; }
.toast { background: var(--modal-bg); backdrop-filter: blur(15px); border: 1px solid var(--glass-border); padding: 1rem 1.2rem; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); display: flex; align-items: center; gap: 12px; color: var(--text-main); font-weight: 500; font-size: 0.95rem; animation: slideInRight 0.4s ease, fadeOut 0.4s ease 3.6s forwards; max-width: 350px; position: relative; overflow: hidden; }
.toast::before { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 4px; }
.toast.success::before { background-color: #10b981; }
.toast.error::before { background-color: #ef4444; }
.toast.warning::before { background-color: #f59e0b; }
.toast.info::before { background-color: #3b82f6; } /* COLOR AZUL PARA MENSAJES */

@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; display: none; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1024px) {
    .dash-container { flex-direction: column; }
    .sidebar { width: 100%; display: flex; flex-wrap: wrap; }
    .sidebar .section-title { width: 100%; text-align: center; }
    .sidebar a { flex: 1 1 calc(33.333% - 20px); text-align: center; justify-content: center; }
}

/* ====================================================
   OTA ADMIN ANDROID / WINDOWS
==================================================== */
.ota-admin-card {
    max-width: 980px;
    margin-bottom: 1.5rem;
}

.ota-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1rem;
}

.ota-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    display: block;
    margin-bottom: 7px;
}

.ota-upload-box {
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    padding: 1.3rem;
    text-align: center;
    margin-top: 1rem;
    background: var(--input-bg);
}

.ota-flags {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 1rem;
    color: var(--text-main);
    font-weight: 700;
}

.ota-flags label {
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 820px) {
    .ota-grid {
        grid-template-columns: 1fr;
    }
}
