/* ============================================
   Cafe Lunacia - Sistem Inventaris Harian
   Mobile-First CSS
   ============================================ */

/* --- Reset / Normalize --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #1a73e8;
    text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

img { max-width: 100%; height: auto; }

/* --- Container --- */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
    flex: 1;
}

/* --- Navbar --- */
.navbar {
    background: #1a1a2e;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
}

.nav-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    display: block;
    padding: 8px;
}

.nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: #1a1a2e;
    padding: 8px 16px 16px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.nav-links.open {
    display: block;
}

.nav-link {
    display: block;
    color: #ccc;
    padding: 10px 0;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.nav-link:last-child { border-bottom: none; }

.nav-link:hover, .nav-link.active {
    color: #fff;
}

.nav-logout {
    color: #ff6b6b;
    margin-top: 8px;
}

/* --- Page Header --- */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    text-wrap: balance;
}

.page-header h2,
.section h2 {
    text-wrap: balance;
}

.date-display {
    color: #666;
    font-size: 0.95rem;
    margin-top: 4px;
}

/* --- Summary Cards --- */
.summary-cards {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.card {
    flex: 1;
    background: #fff;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border-top: 4px solid transparent;
    transition: transform 0.15s ease-out;
}

.card:hover { transform: translateY(-2px); }

.card-icon { font-size: 1.5rem; margin-bottom: 4px; }

.card-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
}

.card-label {
    font-size: 0.85rem;
    color: #666;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-minus { border-top-color: #dc3545; }
.card-minus .card-value { color: #dc3545; }

.card-ok { border-top-color: #28a745; }
.card-ok .card-value { color: #28a745; }

.card-plus { border-top-color: #ffc107; }
.card-plus .card-value { color: #d4a400; }

/* --- Sections --- */
.section {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.section h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #1a1a2e;
}

.section-subtitle {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* --- Tables --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 600px;
    font-variant-numeric: tabular-nums;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #555;
    letter-spacing: 0.3px;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

/* Center-align area & qty columns across tables */
.table td:nth-child(2),
.table td:nth-child(3),
.table th:nth-child(2),
.table th:nth-child(3) {
    text-align: center;
}

.table td:last-child,
.table th:last-child {
    text-align: center;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table-danger thead th {
    background: #fff5f5;
    border-bottom-color: #dc3545;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: #999;
}

.empty-state p { font-size: 1rem; }

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, transform 0.1s;
    min-height: 44px;
}

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

.btn-primary {
    background: #1a73e8;
    color: #fff;
}

.btn-primary:hover { background: #1557b0; }

.btn-block {
    display: block;
    width: 100%;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a73e8;
    color: #fff;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-action:hover { background: #1557b0; }

.btn-outline {
    background: transparent;
    color: #1a73e8;
    border: 2px solid #1a73e8;
}

.btn-outline:hover { background: #e8f0fe; }

/* --- Secondary (icon) buttons --- */
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease-out;
    min-height: 36px;
    background: #e8f0fe;
    color: #1a73e8;
}

.btn-icon:hover { background: #d2e3fc; }
.btn-icon:active { transform: scale(0.97); }

/* --- Action Buttons Grid --- */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.action-buttons .btn-outline {
    grid-column: 1 / -1;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #444;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    min-height: 44px;
    transition: border-color 0.2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

/* --- Filter Bar --- */
.filter-bar {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 120px; }

/* --- Flash Messages --- */
.flash-container {
    max-width: 1000px;
    margin: 12px auto 0;
    padding: 0 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: flashIn 0.3s ease;
}

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

.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

.flash-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 4px 8px;
}

.flash-close:hover { opacity: 1; }

/* --- Login Page --- */
.login-page {
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 24px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 28px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: 8px; }

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.login-subtitle {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.login-form .form-group { text-align: left; }

.login-form .btn { margin-top: 8px; }

.login-page .flash-container {
    max-width: 400px;
    margin: 0 auto 12px;
    padding: 0;
}

/* --- Error Pages --- */
.error-page {
    text-align: center;
    padding: 60px 20px;
}

.error-icon { font-size: 4rem; margin-bottom: 16px; }

.error-page h1 {
    font-size: 4rem;
    font-weight: 800;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.error-page p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 24px;
}

.text-muted { color: #999; }

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 16px;
    color: #999;
    font-size: 0.8rem;
    border-top: 1px solid #eee;
    margin-top: auto;
}

/* --- Utility --- */
.text-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-red { color: #dc3545; }
.text-green { color: #28a745; }
.text-yellow { color: #d4a400; }

/* ============================================
   Desktop (≥768px)
   ============================================ */
@media (min-width: 768px) {
    .container { padding: 24px; }

    .nav-toggle { display: none; }

    .nav-links {
        display: flex !important;
        position: static;
        background: none;
        padding: 0;
        box-shadow: none;
        gap: 4px;
        flex-wrap: nowrap;
    }

    .nav-link {
        padding: 8px 10px;
        border-bottom: none;
        border-radius: 6px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .nav-link:hover { background: rgba(255,255,255,0.1); }

    .nav-logout {
        margin-left: 8px;
        margin-top: 0;
    }

    .summary-cards { gap: 16px; }

    .card-value { font-size: 2.5rem; }

    .page-header h1 { font-size: 1.8rem; }

    .action-buttons {
        grid-template-columns: repeat(3, 1fr);
    }

    .action-buttons .btn-outline {
        grid-column: auto;
    }

    .filter-bar { flex-wrap: nowrap; }
}

/* ============================================
   Analysis Page
   ============================================ */
.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.summary-icon { font-size: 1.3rem; margin-bottom: 4px; }
.summary-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
}
.summary-label {
    font-size: 0.85rem;
    color: #666;
    margin-top: 2px;
}
.summary-detail {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

.minus-card { border-top: 4px solid #dc3545; }
.minus-card .summary-value { color: #dc3545; }
.ok-card { border-top: 4px solid #28a745; }
.ok-card .summary-value { color: #28a745; }
.plus-card { border-top: 4px solid #ffc107; }
.plus-card .summary-value { color: #d4a400; }
.net-card { border-top: 4px solid #6c757d; }

.status-minus { background: #fff5f5; }
.status-plus { background: #fff9e6; }
.status-ok { }

.variance-value { font-weight: 700; }
.variance-minus { color: #dc3545; }
.variance-plus { color: #d4a400; }
.variance-ok { color: #28a745; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-dapur { background: #fff3cd; color: #856404; }
.badge-bar { background: #d1ecf1; color: #0c5460; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #555;
}
.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}
.data-table tbody tr:hover { background: #f8f9fa; }

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
}

.empty-icon { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ============================================
   Count Pages (Dapur + Bar)
   ============================================ */
.count-grid { display: flex; flex-direction: column; gap: 8px; }
.count-item {
    background: #fff; border-radius: 8px; padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-left: 4px solid #ddd;
    transition: border-color 0.15s ease-out;
}
.count-item.filled { border-left-color: #28a745; }
.count-item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.count-item-sku { font-size: 0.75rem; color: #999; font-family: monospace; }
.count-item-name { font-weight: 600; font-size: 0.95rem; flex: 1; }
.count-item-unit { font-size: 0.8rem; color: #888; }
.count-item-fields { display: flex; gap: 8px; }
.count-item-fields.single .field-group { flex: 1; }
.count-item-fields.dual .field-group { flex: 1; }
.field-group label { display: block; font-size: 0.75rem; color: #888; margin-bottom: 2px; }
.field-group input {
    width: 100%; padding: 10px 8px; border: 2px solid #e0e0e0; border-radius: 6px;
    font-size: 1rem; min-height: 44px; text-align: center; font-weight: 600;
    background: #fafafa;
}
.field-group input:focus { border-color: #1a73e8; outline: none; background: #fff; }
.field-group input[readonly] { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
.count-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; padding-bottom: 40px; }
.progress-bar {
    height: 8px; background: #e0e0e0; border-radius: 4px; overflow: hidden; margin-bottom: 16px;
}
.progress-fill { height: 100%; background: #28a745; border-radius: 4px; transition: width 0.3s; }

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 768px) {
    .filter-row { flex-wrap: nowrap; }
}
