@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #1a73e8; /* Google Blue */
    --primary-bg: #f8f9fa;
    --bg-base: #f0f2f5;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f1f3f4;
    --border-light: #e0e0e0;
    --border-focus: #1a73e8;
    --text-main: #202124;
    --text-muted: #5f6368;
    --success: #1e8e3e;
    --warning: #f9ab00;
    --danger: #d93025;
}

html, body {
    margin: 0; padding: 0;
    width: 100vw; min-height: 100vh;
    background-color: var(--bg-base);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

body { color: var(--text-main); display: flex; flex-direction: column; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.03em; color: var(--text-main); }
h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
p.subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 2rem; line-height: 1.5; }

.glass-panel, .glass-card {
    background: var(--bg-card); border: 1px solid var(--border-light);
    border-radius: 12px; padding: 1.5rem;
}

.form-group { margin-bottom: 1.5rem; }
label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
input, select, textarea {
    width: 100%; padding: 0.85rem 1rem; background: var(--bg-input);
    border: 1px solid var(--border-light); border-radius: 8px;
    color: var(--text-main); font-size: 0.95rem; outline: none; transition: all 0.2s ease;
    -webkit-appearance: none;
}
input::placeholder { color: #888888; }
input:focus, select:focus, textarea:focus { border-color: var(--border-focus); background: var(--bg-card); }

.btn, .btn-primary {
    background: var(--primary); color: #ffffff; border: none;
    padding: 0.85rem 1.5rem; border-radius: 8px; font-weight: 600;
    font-size: 0.95rem; cursor: pointer; transition: all 0.2s;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; text-decoration: none;
    width: 100%; /* Default full width for mobile */
}
.btn:hover, .btn-primary:hover { background: #1557b0; }
.btn-outline { background: transparent; border: 1px solid var(--border-light); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-hover); border-color: var(--primary); color: var(--primary); }

/* =========================================
   LAYOUT: DESKTOP (Sidebar Izquierdo)
========================================= */
.admin-layout { display: flex; width: 100%; min-height: 100vh; position: relative; }

/* Sidebar Desktop */
.sidebar {
    width: 260px; background: var(--bg-card); border-right: 1px solid var(--border-light);
    padding: 1.5rem 1rem; display: flex; flex-direction: column; overflow-y: auto; z-index: 100;
    flex-shrink: 0;
}
.mobile-close-btn { display: none; }
.mobile-header { display: none; }
@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%); transition: transform 0.3s ease; }
    .sidebar.active { transform: translateX(0); }
    .mobile-close-btn { display: block; position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--text-main); cursor: pointer; }
    .main-content { width: 100%; }
    
    .mobile-header {
        display: flex; align-items: center; justify-content: flex-start; gap: 1rem;
        padding: 1rem; background: var(--bg-card); border-bottom: 1px solid var(--border-light);
        position: sticky; top: 0; z-index: 90; width: 100%;
    }
    .mobile-menu-btn { background: none; border: none; color: var(--text-main); font-size: 1.5rem; cursor: pointer; padding: 0.5rem; display: flex; align-items: center; justify-content: center; }
}
.sidebar-logo { font-size: 1.2rem; font-weight: 700; margin-bottom: 2rem; display: flex; align-items: center; gap: 0.75rem; color: var(--text-main); }
.sidebar-logo i { color: var(--text-main); }
.user-profile {
    display: flex; align-items: center; gap: 1rem; padding: 1rem;
    background: var(--bg-input); border-radius: 12px; border: 1px solid var(--border-light);
    margin-bottom: 2rem;
}
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 600; color: white;
}
.nav-menu { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-link {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
    color: var(--text-muted); text-decoration: none; border-radius: 8px;
    font-weight: 500; font-size: 0.9rem; transition: all 0.2s ease;
}
.nav-link i { width: 18px; height: 18px; }
.nav-link:hover { color: var(--text-main); background: var(--bg-hover); }
.nav-link.active { color: var(--text-main); background: var(--bg-input); border: 1px solid var(--border-light); }

.main-content {
    flex: 1; padding: 2.5rem; overflow-x: hidden; overflow-y: auto;
    width: calc(100% - 260px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.main-content > * {
    width: 100%;
    max-width: 1100px;
}

/* =========================================
   DASHBOARD CARDS (STAT CARDS)
========================================= */
/* Desktop: 4 columnas EXACTAS. Mobile: 1 columna con Gap */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 1.5rem; 
    margin-bottom: 2rem; 
}
.stat-card { background: var(--bg-card); border: 1px solid var(--border-light); padding: 1.5rem; border-radius: 12px; }
.stat-card h3 { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.5rem; }
.stat-card .value { font-size: 2rem; font-weight: 600; color: var(--text-main); }

/* Tables Premium */
.table-container { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 12px; padding: 0; overflow: hidden; width: 100%; }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; display: block; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { text-align: left; padding: 1rem; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; border-bottom: 1px solid var(--border-light); background: var(--bg-input); }
td { padding: 1rem; border-bottom: 1px solid var(--border-light); color: var(--text-main); font-size: 0.9rem; }

.status-badge { padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; display: inline-flex; align-items: center; }
.status-pendiente { background: rgba(249, 171, 0, 0.1); color: #d97706; border: 1px solid rgba(249, 171, 0, 0.2); }
.status-pagado { background: rgba(30, 142, 62, 0.1); color: #047857; border: 1px solid rgba(30, 142, 62, 0.2); }
.status-por-validar { background: rgba(26, 115, 232, 0.1); color: #0369a1; border: 1px solid rgba(26, 115, 232, 0.2); }

.center-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 400px; }

/* Desktop overrides */
@media (min-width: 769px) {
    .btn, .btn-primary { width: auto; }
}

/* Mobile Utilities */
.mobile-topbar { display: none; }
.mobile-menu-btn { display: none; }
.mobile-close-btn { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .admin-layout { flex-direction: column; width: 100%; }
    
    .mobile-topbar {
        display: flex; justify-content: space-between; align-items: center;
        background: var(--bg-card); border-bottom: 1px solid var(--border-light);
        padding: 1rem; position: sticky; top: 0; z-index: 90; width: 100%;
        /* Handle iOS notch */
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    .mobile-topbar .nav-logo { font-weight: 700; font-size: 1.1rem; color: var(--text-main); display: flex; align-items: center; gap: 0.5rem; }
    .mobile-topbar .nav-logo i { color: var(--text-main); }
    .mobile-menu-btn { display: block; background: none; border: none; color: var(--text-main); cursor: pointer; padding: 0.5rem; }
    
    /* Off-canvas sidebar */
    .sidebar {
        position: fixed; top: 0; left: -100%; height: 100vh; width: 280px;
        transition: left 0.3s ease; box-shadow: none; z-index: 1000;
        /* Handle iOS notch */
        padding-top: max(2rem, env(safe-area-inset-top));
    }
    .sidebar.active { left: 0; }
    .mobile-close-btn { display: block; background: none; border: none; color: var(--text-main); position: absolute; top: max(1.5rem, env(safe-area-inset-top)); right: 1.5rem; cursor: pointer; }
    .sidebar .sidebar-logo { display: none; } /* Hide logo inside mobile sidebar */
    
    .sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.8); z-index: 900; }
    .sidebar-overlay.active { display: block; }

    .main-content {
        width: 100%; padding: 1rem; margin: 0;
        /* Handle bottom safe area */
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
    .glass-card { padding: 1rem; border-radius: 8px; }
    
    /* Mobile Stat Cards: 1 Column with GAP (Not stuck together) */
    .stats-grid { grid-template-columns: 1fr; gap: 1rem; }
}
