/* ============================================================
   WORKSHOP MANAGEMENT SYSTEM - STYLES
   Responsive: Desktop, Tablet, Mobile
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --dark: #1e293b;
    --light: #f1f5f9;
    --white: #ffffff;
    --gray: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 240px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--light);
    color: var(--dark);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 18px;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 24px;
    cursor: pointer;
}

.sidebar-nav {
    padding: 10px 0;
}

.nav-link {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: background 0.2s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    text-decoration: none;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--white);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 18px;
    flex: 1;
}

.menu-btn {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--dark);
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.menu-btn:hover {
    background: var(--light);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-name {
    font-weight: 600;
}

.user-role {
    color: var(--gray);
    font-size: 12px;
}

.content {
    padding: 20px;
    flex: 1;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

/* Bottom nav - mobile only */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 5px 0;
}

.bottom-nav-item {
    flex: 1;
    text-align: center;
    padding: 8px 5px;
    font-size: 12px;
    color: var(--gray);
    text-decoration: none;
}

.bottom-nav-item:hover {
    color: var(--primary);
    text-decoration: none;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--dark) 0%, var(--primary-dark) 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 25px;
}

.login-header h1 {
    color: var(--primary);
    font-size: 28px;
}

.login-header p {
    color: var(--gray);
    margin-top: 5px;
}

/* ============================================================
   CARDS & GRIDS
   ============================================================ */

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 {
    font-size: 16px;
}

.card-body {
    padding: 20px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.kpi-card.kpi-warning {
    border-left-color: var(--warning);
}

.kpi-card.kpi-danger {
    border-left-color: var(--danger);
}

.kpi-label {
    color: var(--gray);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 5px;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    text-align: center;
}

.btn:hover {
    text-decoration: none;
    opacity: 0.9;
}

.btn-primary { background: var(--primary); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-info { background: var(--info); color: var(--white); }
.btn-secondary { background: var(--gray); color: var(--white); }
.btn-light { background: var(--light); color: var(--dark); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { display: block; width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

select.form-control {
    appearance: auto;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table th {
    background: var(--light);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray);
}

.table tbody tr:hover {
    background: var(--light);
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-draft, .badge-pending { background: #e2e8f0; color: #475569; }
.badge-waiting, .badge-in_progress, .badge-in-progress { background: #dbeafe; color: #1d4ed8; }
.badge-completed, .badge-paid, .badge-active, .badge-approved { background: #dcfce7; color: #166534; }
.badge-cancelled, .badge-void, .badge-rejected, .badge-suspended { background: #fee2e2; color: #991b1b; }
.badge-qc, .badge-ready, .badge-partial { background: #fef3c7; color: #92400e; }
.badge-waiting_parts { background: #fef3c7; color: #92400e; }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */

.flash-container {
    margin-bottom: 15px;
}

.flash {
    padding: 12px 15px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.flash-info { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }

.flash-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
}

/* ============================================================
   UTILITIES
   ============================================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray); }

.mt-1 { margin-top: 5px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 15px; }
.mb-1 { margin-bottom: 5px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 15px; }

/* ============================================================
   POS LAYOUT
   ============================================================ */

.pos-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.pos-left {
    min-width: 0;
}

.pos-right {
    background: var(--light);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.scan-box {
    background: var(--white);
    padding: 15px;
    border-radius: var(--radius);
    border: 2px solid var(--primary);
}

.scan-box .form-control {
    font-size: 18px;
    padding: 12px;
}

/* POS multi-customer tabs */
.pos-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.pos-tab {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 14px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    color: var(--dark);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.pos-tab:hover {
    border-color: var(--primary);
}

.pos-tab.active {
    border-color: var(--primary);
    background: #eff6ff;
}

.pos-tab-name {
    font-weight: 600;
}

.pos-tab-badge {
    font-size: 11px;
    color: var(--gray);
    background: var(--light);
    padding: 1px 8px;
    border-radius: 20px;
}

.pos-tab.active .pos-tab-badge {
    background: var(--primary);
    color: var(--white);
}

.pos-tab-total {
    font-size: 13px;
    font-weight: 700;
    color: var(--success);
}

.pos-panel {
    display: none;
}

.pos-panel.active {
    display: block;
}

/* POS product search modal */
.pos-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 15px;
}

.pos-modal.open {
    display: flex;
}

.pos-modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 700px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.pos-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pos-modal-header h3 {
    font-size: 15px;
}

.pos-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--gray);
}

.pos-modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Searchable dropdown (pelanggan POS) */
.searchable-select {
    position: relative;
}

.ss-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    max-height: 220px;
    overflow-y: auto;
    z-index: 30;
}

.searchable-select.open .ss-list {
    display: block;
}

.ss-option {
    display: block;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 14px;
    color: var(--dark);
    cursor: pointer;
}

.ss-option:last-child {
    border-bottom: none;
}

.ss-option:hover {
    background: var(--light);
}

.ss-option.selected {
    background: #eff6ff;
    font-weight: 600;
    color: var(--primary);
}

/* ============================================================
   RESPONSIVE - TABLET (<=1024px)
   ============================================================ */

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Sidebar toggle for all screen sizes */
.sidebar {
    transition: transform 0.3s ease;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.main {
    transition: margin-left 0.3s ease;
}

.main.fullscreen {
    margin-left: 0;
}

/* ============================================================
   RESPONSIVE - MOBILE (<=768px)
   ============================================================ */

@media (max-width: 768px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }

    .pos-tabs {
        gap: 6px;
    }

    .pos-tab {
        min-width: calc(33.33% - 4px);
        padding: 8px 6px;
        font-size: 12px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .overlay.show {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .topbar-user .user-name,
    .topbar-user .user-role {
        display: none;
    }

    .content {
        padding: 15px;
        padding-bottom: 70px;
    }

    .bottom-nav {
        display: flex;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-actions {
        flex-direction: column;
    }

    .quick-actions .btn {
        width: 100%;
    }

    /* Convert tables to card view on mobile */
    .table-responsive {
        overflow-x: visible;
    }

    .table {
        display: block;
    }

    .table thead {
        display: none;
    }

    .table tbody {
        display: block;
    }

    .table tbody tr {
        display: block;
        background: var(--white);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 10px;
        box-shadow: var(--shadow);
    }

    .table tbody tr:hover {
        background: var(--white);
    }

    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 10px;
        border-bottom: 1px solid var(--border);
        white-space: normal;
        text-align: right;
    }

    .table td:last-child {
        border-bottom: none;
    }

    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--gray);
        margin-right: 10px;
        text-align: left;
        flex-shrink: 0;
    }

    .table td:first-child {
        font-weight: 600;
        font-size: 14px;
        color: var(--primary);
    }

    .table td:first-child::before {
        display: none;
    }

    .table td .btn {
        margin: 2px;
    }

    .table tfoot {
        display: block;
    }

    .table tfoot tr {
        display: block;
        background: var(--light);
        border-radius: var(--radius);
        padding: 10px;
    }

    .table tfoot th {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 10px;
        border-bottom: 1px solid var(--border);
        white-space: normal;
        text-align: right;
    }

    .table tfoot th:last-child {
        border-bottom: none;
    }
}

/* ============================================================
   RESPONSIVE - SMALL MOBILE (<=480px)
   ============================================================ */

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .table th,
    .table td {
        padding: 8px;
        font-size: 13px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-header .btn {
        width: 100%;
    }

    .topbar {
        padding: 10px 12px;
    }

    .topbar h1 {
        font-size: 16px;
    }
}