/* ─────────────────────────────────────────────
   JP Distribuidora — Design System v4.0
   Corporate Command · Light Banking · Sharp
   ───────────────────────────────────────────── */

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

:root {
    --primary: #e67e22;
    --primary-hover: #d35400;
    --primary-glow: rgba(230, 126, 34, 0.08);
    --bg-dark: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fa;
    --text-main: #111827;
    --text-muted: #6b7280;
    --success: #059669;
    --success-glow: rgba(5, 150, 105, 0.06);
    --danger: #dc2626;
    --danger-glow: rgba(220, 38, 38, 0.06);
    --border: #e5e7eb;
    --radius: 8px;
    --transition: 0.2s ease;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --header-bg: #1e293b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html { scroll-behavior: smooth; }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    padding-bottom: 80px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Splash Screen ─── */
.splash-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: var(--header-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.splash-logo {
    width: 100px;
    height: auto;
    animation: splashFade 1s ease-out forwards;
}

.splash-bar {
    width: 120px;
    height: 2px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    overflow: hidden;
}

.splash-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 2px;
    animation: splashLoad 1.4s ease-out forwards;
}

.splash-hide {
    opacity: 0;
    transform: scale(1.02);
    pointer-events: none;
}

@keyframes splashFade {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes splashLoad {
    0% { width: 0%; }
    40% { width: 55%; }
    80% { width: 88%; }
    100% { width: 100%; }
}

/* ─── Glass → Clean Card Override ─── */
.glass {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

/* ─── Header ─── */
.app-header {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    border-bottom: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.header-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 6px;
}

/* ─── Container ─── */
.container {
    padding: 16px 20px;
    max-width: 600px;
    margin: 0 auto;
}

/* ─── Page Transitions ─── */
.page-transition {
    animation: pageIn 0.3s ease-out forwards;
}

.page-exit {
    animation: pageOut 0.15s ease-in forwards;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes pageOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ─── Toast Messages ─── */
.toast-success {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 30px;
    background: var(--success);
    color: white;
    box-shadow: 0 10px 25px -5px rgba(5, 150, 105, 0.4);
    font-size: 0.9rem;
    font-weight: 600;
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: none;
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -20px) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translate(-50%, 0) scale(1); }
    to { opacity: 0; transform: translate(-50%, -20px) scale(0.9); }
}

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    transition: transform var(--transition), box-shadow var(--transition);
    animation: cardIn 0.25s ease-out backwards;
}

.card:nth-child(1) { animation-delay: 0.03s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.09s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.15s; }
.card:nth-child(6) { animation-delay: 0.18s; }

@keyframes cardIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.card:active {
    transform: scale(0.985);
}

a.card {
    text-decoration: none;
    color: inherit;
}

a.card:hover, a.card:focus {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-md);
    border-color: #d1d5db;
}

.card-title {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-main);
}

/* ─── Forms ─── */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

input, select, textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder, textarea::placeholder {
    color: #9ca3af;
}

textarea {
    resize: vertical;
    min-height: 60px;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* ─── Buttons ─── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
    color: var(--text-main);
    font-family: inherit;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

/* ─── Bottom Navigation ─── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -1px 3px rgba(0,0,0,0.04);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #9ca3af;
    font-size: 0.58rem;
    font-weight: 600;
    transition: color var(--transition);
    padding: 4px 8px;
    position: relative;
    letter-spacing: 0.02em;
}

.nav-item i {
    width: 20px;
    height: 20px;
    margin-bottom: 2px;
    stroke-width: 2px;
}

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

.nav-item.active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--primary);
    border-radius: 0 0 2px 2px;
}

/* ─── Modals ─── */
[id^="modal-"] {
    animation: modalIn 0.25s ease-out forwards;
}

@keyframes modalIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

[id^="modal-"] > div {
    animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Utility Classes ─── */
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.gap-2 { gap: 8px; }

/* ─── Animations ─── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ─── Responsive ─── */
@media (max-width: 380px) {
    .container { padding: 12px 14px; }
    .card { padding: 16px; }
    .header-logo { width: 44px; height: 44px; }
}

@media (min-width: 601px) {
    .container { max-width: 600px; }
    .bottom-nav { max-width: 600px; left: 50%; transform: translateX(-50%); border-radius: 12px 12px 0 0; }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── Print Only ─── */
.print-only { display: none !important; }

/* ─── Print Styles ─── */
@media print {
    .print-only { display: block !important; }
    .no-print, .app-header, .bottom-nav, .splash-screen { display: none !important; }
    
    body {
        background: white !important;
        color: #111 !important;
        padding: 0 !important;
        font-size: 11pt;
    }
    
    .container {
        max-width: 100% !important;
        padding: 10px 20px !important;
    }
    
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    a { color: inherit !important; text-decoration: none !important; }
    
    .card-title { color: #555 !important; }
    .card-value { color: #111 !important; }
}

/* ─── Searchable Select ─── */
.searchable-select {
    position: relative;
}

.searchable-input {
    width: 100%;
    cursor: text;
}

.search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1.5px solid var(--primary);
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: var(--shadow-lg);
}

.search-dropdown.open {
    display: block;
    animation: dropIn 0.15s ease-out;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-item {
    padding: 10px 14px;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--border);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover,
.search-item.highlighted {
    background: var(--primary-glow);
    color: var(--primary);
}

.search-empty {
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: default;
    font-style: italic;
}

.search-empty:hover {
    background: transparent;
    color: var(--text-muted);
}
