/* ============================================================
   Style CSS - Aplikasi Warkop POS
   ============================================================ */

/* === Global === */
:root {
    --primary: #6f42c1;
    --primary-dark: #553098;
    --primary-light: #e8dff5;
    --secondary: #ffc107;
    --success: #28a745;
    --danger: #dc3545;
    --dark: #343a40;
    --gray: #6c757d;
    --light: #f8f9fa;
    --sidebar-width: 250px;
    --sidebar-collapsed: 70px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f6f9;
    min-height: 100vh;
}

a {
    text-decoration: none;
}

/* === Login Page === */
.login-page {
    background: linear-gradient(135deg, var(--primary) 0%, #4a2c8a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: #fff;
    border-radius: 15px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-box .logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-box .logo h1 {
    color: var(--primary);
    font-weight: 700;
    font-size: 28px;
}

.login-box .logo p {
    color: var(--gray);
    font-size: 14px;
    margin-top: 5px;
}

.login-box .form-control {
    height: 48px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    padding: 10px 15px;
    font-size: 14px;
}

.login-box .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.15);
}

.login-box .btn-login {
    height: 48px;
    border-radius: 10px;
    background: var(--primary);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s;
}

.login-box .btn-login:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(111, 66, 193, 0.3);
}

/* === Wrapper & Sidebar === */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #2d1b69 0%, var(--primary) 100%);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Collapsed state: sembunyikan sidebar (desktop & mobile) */
.sidebar.collapsed {
    transform: translateX(calc(var(--sidebar-width) * -1));
}

.sidebar .brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .brand h3 {
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    margin: 0;
}

.sidebar .brand small {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.sidebar .nav-menu {
    padding: 15px 0;
}

.sidebar .nav-item {
    list-style: none;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s;
    gap: 12px;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--secondary);
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar .nav-link .badge {
    margin-left: auto;
}

/* === Main Content === */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    transition: all 0.3s ease;
    width: calc(100% - var(--sidebar-width));
}

/* Saat sidebar di-collapse, konten melebar penuh */
.content.expanded {
    margin-left: 0;
    width: 100%;
}

/* === Navbar === */
.navbar-top {
    background: #fff;
    padding: 12px 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 99;
}

.navbar-top .left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-top .toggle-sidebar {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--dark);
    cursor: pointer;
    padding: 5px;
}

.navbar-top .page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

.navbar-top .right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar-top .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-top .user-info .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* === Page Content === */
.page-content {
    padding: 25px;
}

/* === Cards === */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.3s;
    margin-bottom: 20px;
}

.card:hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    padding: 18px 20px;
    font-weight: 600;
    border-radius: 12px 12px 0 0 !important;
}

.card-body {
    padding: 20px;
}

/* === Stat Cards === */
.stat-card {
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-card .icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.stat-card .info h3 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

.stat-card .info p {
    margin: 0;
    opacity: 0.85;
    font-size: 14px;
}

.stat-purple { background: linear-gradient(135deg, #6f42c1, #553098); }
.stat-warning { background: linear-gradient(135deg, #ffc107, #e0a800); }
.stat-success { background: linear-gradient(135deg, #28a745, #1e7e34); }
.stat-info { background: linear-gradient(135deg, #17a2b8, #117a8b); }

/* === Tables === */
.table-container {
    overflow-x: auto;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 2px solid #f0f0f0;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--gray);
    padding: 12px 10px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 10px;
    vertical-align: middle;
    font-size: 14px;
}

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

/* === Buttons === */
.btn {
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* === Forms === */
.form-label {
    font-weight: 500;
    font-size: 14px;
    color: var(--dark);
    margin-bottom: 5px;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid #e0e0e0;
    padding: 10px 12px;
    font-size: 14px;
    transition: all 0.3s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.1);
}

/* === POS Page === */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
}

.pos-products {
    min-width: 0;
}

.pos-products .card-body {
    max-height: calc(100vh - 230px);
    overflow-y: auto;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

.product-item {
    background: #fff;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.product-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(111, 66, 193, 0.15);
}

.product-item .product-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 24px;
    color: var(--primary);
}

.product-item .product-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 32px;
}

.product-item .product-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.btn-add-pos {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-add-pos:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* === Cart POS (Right Sidebar) === */
.pos-cart .card {
    position: sticky;
    top: 90px;
}

.pos-cart .card-body {
    max-height: calc(100vh - 450px);
    overflow-y: auto;
    padding: 10px 15px;
}

.cart-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.cart-item-info {
    flex: 1;
    min-width: 120px;
}

.cart-item-name {
    font-size: 13px;
    font-weight: 600;
}

.cart-item-price {
    font-size: 11px;
    color: var(--gray);
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-qty {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-qty-minus:hover {
    background: #ffe0e0;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-qty-plus:hover {
    background: #d4edda;
    border-color: var(--success);
    color: var(--success);
}

.btn-qty-del {
    color: var(--danger);
    font-size: 12px;
    border-color: transparent;
}

.btn-qty-del:hover {
    background: var(--danger);
    color: #fff;
}

.qty-value {
    width: 30px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
}

.cart-item-subtotal {
    width: 100%;
    text-align: right;
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}

.cart-summary {
    padding: 5px 0;
}

/* === Struk / Receipt === */
.struk-wrapper {
    display: none;
}

.struk {
    width: 280px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.struk .header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #000;
}

.struk .header h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 5px;
}

.struk .header p {
    margin: 2px 0;
    font-size: 11px;
}

.struk .items {
    margin-bottom: 15px;
}

.struk .items .item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.struk .items .item .left {
    flex: 1;
}

.struk .items .item .right {
    text-align: right;
}

.struk .total {
    border-top: 1px dashed #000;
    padding-top: 10px;
}

.struk .total .row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}

.struk .total .grand {
    font-size: 16px;
    font-weight: 700;
    border-top: 1px dashed #000;
    padding-top: 8px;
    margin-top: 5px;
}

.struk .footer {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #000;
    font-size: 11px;
}

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

/* === Responsive === */
@media (max-width: 992px) {
    /* Di mobile, sidebar tersembunyi by default */
    .sidebar {
        transform: translateX(calc(var(--sidebar-width) * -1));
    }
    /* Tampilkan sidebar mobile saat tidak collapsed */
    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }
    /* Overlay saat sidebar terbuka di mobile */
    .sidebar-overlay {
        display: block;
        opacity: 1;
        pointer-events: all;
    }
    .content {
        margin-left: 0;
        width: 100%;
    }
    /* Di mobile, expanded = sidebar terbuka (konten tidak bergeser) */
    .content.expanded {
        margin-left: 0;
        width: 100%;
    }
    .pos-container {
        grid-template-columns: 1fr;
    }
    .pos-cart .card {
        position: static;
    }
    .pos-products .card-body {
        max-height: none;
    }
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
}

/* Overlay gelap saat sidebar terbuka di mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

@media (max-width: 576px) {
    .page-content {
        padding: 15px;
    }
    .login-box {
        padding: 25px;
        margin: 15px;
    }
    .stat-card {
        flex-direction: column;
        text-align: center;
    }
    .navbar-top {
        padding: 10px 15px;
    }
    .navbar-top .page-title {
        font-size: 15px;
    }
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
        gap: 8px;
    }
    .product-item {
        padding: 10px;
    }
    .product-item .product-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    .product-item .product-name {
        font-size: 11px;
    }
}