/* ============================================
   STOCKBOX - STYLE CSS
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f1729;
    color: #f1f5f9;
    padding-bottom: 80px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ----- HEADER ----- */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #0f1729;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.title {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #1a2332;
    border-radius: 20px;
    font-size: 13px;
    color: #94a3b8;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.dot.online { background: #4ade80; }
.dot.offline { background: #f87171; }
.dot.syncing { background: #fbbf24; animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ----- BOTTOM NAV ----- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: #1a2332;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 10px;
    cursor: pointer;
    transition: 0.2s;
    min-width: 50px;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
}

.nav-item .nav-icon {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-item.active {
    color: #4ade80;
}

.nav-item.nav-center {
    margin-top: -20px;
    background: #4ade80;
    color: #0f1729;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(74, 222, 128, 0.3);
}

.nav-item.nav-center .nav-icon {
    width: 26px;
    height: 26px;
    stroke: #0f1729;
    stroke-width: 2.5;
}

.nav-item:active { transform: scale(0.92); }

/* ----- MAIN ----- */
.main {
    padding: 16px;
    max-width: 480px;
    margin: 0 auto;
}

/* ----- PAGES ----- */
.page { display: none; }
.page.active { display: block; animation: fadeUp 0.3s ease; }

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

.page-header { margin-bottom: 16px; }
.page-header h1 { font-size: 20px; font-weight: 700; }
.page-header p { font-size: 13px; color: #94a3b8; }

/* ----- STATS ----- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: rgba(26, 35, 50, 0.85);
    border-radius: 16px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-card .stat-icon {
    width: 28px;
    height: 28px;
    stroke: #4ade80;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    margin-bottom: 4px;
}

.stat-card .label {
    font-size: 11px;
    color: #94a3b8;
    display: block;
}

.stat-card .value {
    font-size: 20px;
    font-weight: 700;
}
.stat-card .value.green { color: #4ade80; }
.stat-card .value.yellow { color: #fbbf24; }
.stat-card .value.red { color: #f87171; }

/* ----- LOW STOCK ----- */
.low-stock {
    background: rgba(26, 35, 50, 0.85);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.low-stock h3 {
    font-size: 14px;
    color: #fbbf24;
    margin-bottom: 10px;
}

.low-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 14px;
}
.low-item:last-child { border-bottom: none; }
.low-item .qty { color: #f87171; font-weight: 600; }

/* ----- TOOLBAR ----- */
.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.toolbar input,
.toolbar select {
    padding: 10px 14px;
    background: #1a2332;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: #f1f5f9;
    font-size: 14px;
    outline: none;
    min-height: 44px;
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
}

.toolbar input::placeholder { color: #64748b; }
.toolbar input:focus,
.toolbar select:focus { border-color: #4ade80; }

/* ----- PRODUCT ITEM ----- */
.product-item {
    background: rgba(26, 35, 50, 0.85);
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.product-item .info { flex: 1; min-width: 0; }
.product-item .name { font-weight: 600; font-size: 14px; }
.product-item .meta {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.product-item .stock {
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 20px;
    background: #1a2332;
    font-size: 14px;
    flex-shrink: 0;
}
.product-item .stock.low { color: #f87171; }
.product-item .stock.normal { color: #4ade80; }

.product-item .actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.product-item .actions button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #1a2332;
    cursor: pointer;
    color: #94a3b8;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.product-item .actions button:active { transform: scale(0.85); }
.product-item .actions .edit { color: #4ade80; }
.product-item .actions .del { color: #f87171; }

.product-item .actions button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ----- EMPTY ----- */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}
.empty .empty-icon {
    width: 48px;
    height: 48px;
    stroke: #64748b;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    margin-bottom: 8px;
}
.empty p { font-size: 14px; }

/* ----- MODAL ----- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: #1a2332;
    border-radius: 16px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(26, 35, 50, 0.85);
    border-radius: 50%;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
.modal-body { padding: 16px 20px 20px; }

/* ----- FORM ----- */
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 3px;
    font-weight: 500;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: #0f1729;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: #f1f5f9;
    font-size: 14px;
    outline: none;
    min-height: 42px;
    -webkit-appearance: none;
    appearance: none;
}
.form-group input:focus,
.form-group select:focus { border-color: #4ade80; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.form-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    transition: 0.2s;
}
.form-actions button:active { transform: scale(0.97); }
.form-actions .btn-primary {
    background: #4ade80;
    color: #0f1729;
}
.form-actions .btn-secondary {
    background: rgba(26, 35, 50, 0.85);
    color: #94a3b8;
}

/* ----- BACKUP ----- */
.backup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.backup-card {
    background: rgba(26, 35, 50, 0.85);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center;
}
.backup-card .backup-icon {
    width: 32px;
    height: 32px;
    stroke: #4ade80;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.backup-card h3 {
    font-size: 15px;
    margin: 6px 0;
    font-weight: 600;
}
.backup-card p {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 10px;
}
.backup-card button {
    padding: 8px 20px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.backup-card button:active { transform: scale(0.95); }
.backup-card .btn-green {
    background: #4ade80;
    color: #0f1729;
}
.backup-card .btn-gray {
    background: #1a2332;
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ----- SYNC ----- */
.sync-status {
    background: rgba(26, 35, 50, 0.85);
    border-radius: 16px;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}
.sync-status .sync-icon {
    width: 32px;
    height: 32px;
    stroke: #4ade80;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.sync-status .info h3 {
    font-size: 15px;
    font-weight: 600;
}
.sync-status .info p {
    font-size: 13px;
    color: #94a3b8;
}

.sync-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.sync-actions button {
    flex: 1;
    min-width: 100px;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    transition: 0.2s;
}
.sync-actions button:active { transform: scale(0.97); }
.sync-actions .btn-primary {
    background: #4ade80;
    color: #0f1729;
}
.sync-actions .btn-secondary {
    background: rgba(26, 35, 50, 0.85);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.sync-actions .btn-danger {
    background: #f87171;
    color: #0f1729;
}

/* ----- SETTINGS ----- */
.setting-group {
    background: rgba(26, 35, 50, 0.85);
    border-radius: 16px;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 10px;
}
.setting-group h3 {
    font-size: 14px;
    font-weight: 600;
}
.setting-group p {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 8px;
}
.setting-group .control {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.setting-group .control input[type="number"] {
    width: 70px;
    padding: 8px 10px;
    background: #0f1729;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: #f1f5f9;
    font-size: 14px;
    min-height: 38px;
    -webkit-appearance: none;
    appearance: none;
}
.setting-group .control button {
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 38px;
    transition: 0.2s;
}
.setting-group .control button:active { transform: scale(0.95); }
.setting-group .control .btn-primary {
    background: #4ade80;
    color: #0f1729;
}
.setting-group .control .btn-danger {
    background: #f87171;
    color: #0f1729;
}
.setting-group.danger {
    border-color: rgba(248, 113, 113, 0.3);
}
.setting-group.danger h3 { color: #f87171; }

.setting-group .setting-info {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.8;
}
.setting-group .setting-info strong {
    color: #f1f5f9;
}

/* ----- TOAST ----- */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 24px;
    background: #1a2332;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: #f1f5f9;
    font-size: 14px;
    font-weight: 500;
    z-index: 999;
    opacity: 0;
    transition: all 0.4s ease;
    max-width: 90%;
    text-align: center;
    pointer-events: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: #4ade80; }
.toast.error { border-color: #f87171; }
.toast.warning { border-color: #fbbf24; }

/* ----- RESPONSIVE ----- */
@media (min-width: 640px) {
    .main { max-width: 600px; padding: 24px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
    .main { max-width: 800px; padding: 32px; }
    .stats-grid { grid-template-columns: repeat(5, 1fr); }
    .bottom-nav {
        max-width: 500px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-card .value { font-size: 17px; }
    .form-row { grid-template-columns: 1fr; }
    .backup-grid { grid-template-columns: 1fr; }
    .sync-actions button { min-width: 80px; font-size: 13px; padding: 10px; }
    .product-item { padding: 10px 12px; flex-wrap: wrap; }
    .product-item .stock { font-size: 12px; padding: 2px 8px; }
    .modal { max-width: 100%; margin: 10px; }
    .toolbar { flex-direction: column; }
    .toolbar input, .toolbar select { width: 100%; }
}

/* ----- SCROLLBAR ----- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #4ade80; border-radius: 4px; }

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f1729;
    padding: 20px;
}

.login-box {
    background: #1a2332;
    border-radius: 24px;
    padding: 40px 32px;
    max-width: 400px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-box .login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.login-box .login-logo svg {
    width: 32px;
    height: 32px;
    stroke: #4ade80;
}

.login-box .login-logo span {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-box h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #f1f5f9;
}

.login-box p {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 24px;
}

.login-box .form-group {
    margin-bottom: 16px;
}

.login-box .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 4px;
}

.login-box .form-group input {
    width: 100%;
    padding: 12px 14px;
    background: #0f1729;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: #f1f5f9;
    font-size: 15px;
    outline: none;
    min-height: 48px;
    transition: 0.2s;
}

.login-box .form-group input:focus {
    border-color: #4ade80;
}

.login-box .btn-login {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: #4ade80;
    color: #0f1729;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    min-height: 48px;
}

.login-box .btn-login:hover {
    background: #22c55e;
}

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

.login-box .login-error {
    color: #f87171;
    font-size: 14px;
    margin-top: 12px;
    text-align: center;
    min-height: 24px;
}

.login-box .login-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 16px;
}

.login-box .login-footer strong {
    color: #94a3b8;
}

/* ============================================
   HEADER - LAYOUT UTAMA
   ============================================ */

.header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #0f1729;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 60px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left .logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.header-left .title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============================================
   TOMBOL LOGOUT - PROFESIONAL
   ============================================ */

#btnLogoutHeader {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: 8px;
    color: #f87171;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

#btnLogoutHeader svg {
    width: 16px;
    height: 16px;
    stroke: #f87171;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
    transition: stroke 0.25s ease;
}

#btnLogoutHeader span {
    line-height: 1;
    padding-top: 1px;
}

#btnLogoutHeader:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: #f87171;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(248, 113, 113, 0.15);
}

#btnLogoutHeader:hover svg {
    stroke: #ef4444;
}

#btnLogoutHeader:active {
    transform: scale(0.96);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .header {
        padding: 10px 16px;
        min-height: 52px;
    }
    
    .header-left .title {
        font-size: 18px;
    }
    
    #btnLogoutHeader {
        height: 32px;
        padding: 0 12px;
        font-size: 12px;
        gap: 6px;
    }
    
    #btnLogoutHeader svg {
        width: 14px;
        height: 14px;
    }
}

@media (min-width: 768px) {
    #btnLogoutHeader {
        height: 38px;
        padding: 0 20px;
        font-size: 14px;
        border-radius: 10px;
    }
    
    #btnLogoutHeader svg {
        width: 18px;
        height: 18px;
    }
}