/* static/pwa/css/app.css */
:root {
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    --secondary: #10b981;
    --bg-body: #0f172a;
    --text-main: #f8fafc;
    --text-light: #94a3b8;
    --bg-card: #1e293b;
    --border: #334155;
    
    --app-bar-height: 56px;
    --bottom-nav-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.app-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* ----- TOP APP BAR ----- */
.app-bar {
    height: var(--app-bar-height);
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

.app-bar-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-title i {
    color: var(--secondary);
}

/* ----- SIDE DRAWER ----- */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background-color: var(--bg-card);
    z-index: 2001;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.drawer.active {
    left: 0;
}

.drawer-header {
    height: 120px;
    background-color: var(--primary);
    color: white;
    padding: 24px 16px 16px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.drawer-header h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.drawer-header p {
    font-size: 14px;
    color: var(--secondary);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.drawer-menu {
    list-style: none;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.drawer-menu li a {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    gap: 16px;
}

.drawer-menu li a:active {
    background-color: var(--bg-body);
}

.drawer-menu li a i {
    font-size: 20px;
    color: var(--primary-light);
    width: 24px;
    text-align: center;
}

input, select, textarea {
    background-color: var(--bg-body);
    color: var(--text-main);
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

select {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

/* ----- MAIN CONTENT ----- */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    padding-bottom: calc(16px + var(--bottom-nav-height));
}

/* ----- BOTTOM NAV ----- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background-color: var(--bg-card);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    text-decoration: none;
    font-size: 12px;
    width: 100%;
    height: 100%;
    gap: 4px;
}

.nav-item i {
    font-size: 22px;
}

.nav-item.active {
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--secondary);
}

/* Indicador Offline */
.offline-badge {
    display: none;
    background-color: #d32f2f;
    color: white;
    text-align: center;
    padding: 4px;
    font-size: 12px;
    font-weight: bold;
}

/* Notificaciones Toast */
.toast {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid var(--border);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success i { color: var(--secondary); }
.toast-error i { color: #ef4444; }
.toast-info i { color: var(--primary-light); }
.toast-warning i { color: #f59e0b; }

/* ============================================================
   RESPONSIVIDAD PARA ESCRITORIO (Diseño tipo Unfold)
   ============================================================ */
@media (min-width: 768px) {
    body {
        background-color: var(--bg-body);
    }
    
    .app-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
        box-shadow: none;
    }

    .bottom-nav {
        display: none !important;
    }

    .card {
        max-width: 800px;
        margin: 0 auto;
    }
}

/* ============================================================
   IMPRESIÓN (Receta PDF)
   ============================================================ */
.print-only {
    display: none;
}

@media print {
    body {
        background-color: white !important;
        color: black !important;
    }
    .app-bar, .drawer, .drawer-overlay, .bottom-nav, #pwa-content {
        display: none !important;
    }
    .print-only {
        display: block !important;
        width: 100%;
    }
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }
}
