/* ============================================
   KOPERASI MERAH PUTIH MEJAGONG - STYLES
   Enhanced Mobile-Friendly Version
   ============================================ */

:root {
    --merah: #DC3545;
    --putih: #FFFFFF;
    --merah-dark: #B02A37;
    --merah-light: #F8D7DA;
    --abu: #6C757D;
    --abu-light: #F8F9FA;
    --hijau: #198754;
    --hijau-light: #D1E7DD;
    --biru: #0D6EFD;
    --kuning: #FFC107;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-lg: 20px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--abu-light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   NAVBAR - Mobile Optimized
   ============================================ */
.navbar-merah-putih {
    background: linear-gradient(135deg, var(--merah) 0%, var(--merah-dark) 100%);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
}

.navbar-merah-putih .navbar-brand {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Mobile: Navbar lebih compact */
@media (max-width: 768px) {
    .navbar-merah-putih .navbar-brand {
        font-size: 0.85rem;
        max-width: 70%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .navbar-merah-putih .navbar-toggler {
        padding: 0.25rem 0.5rem;
        font-size: 1rem;
    }
}

/* ============================================
   SIDEBAR - Mobile Friendly
   ============================================ */
.sidebar {
    min-height: calc(100vh - 56px);
    background: linear-gradient(180deg, #2C3E50 0%, #1A252F 100%);
    transition: all 0.3s ease;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.85);
    padding: 14px 20px;
    border-radius: 10px;
    margin: 4px 10px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: var(--merah);
    color: white;
    transform: translateX(5px);
}

.sidebar .nav-link i {
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
}

/* Mobile: Sidebar menjadi bottom navigation atau collapsible */
@media (max-width: 768px) {
    .sidebar {
        min-height: auto;
        padding: 10px 0;
    }
    
    .sidebar .nav-link {
        padding: 12px 15px;
        margin: 2px 8px;
        font-size: 0.9rem;
    }
}

/* ============================================
   CARDS - Touch Friendly
   ============================================ */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-dashboard {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

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

/* Stat Cards */
.card-merah {
    background: linear-gradient(135deg, var(--merah) 0%, var(--merah-dark) 100%);
    color: white;
}

.card-hijau {
    background: linear-gradient(135deg, #198754 0%, #146C43 100%);
    color: white;
}

.card-biru {
    background: linear-gradient(135deg, #0D6EFD 0%, #0B5ED7 100%);
    color: white;
}

.card-kuning {
    background: linear-gradient(135deg, #FFC107 0%, #E0A800 100%);
    color: #333;
}

.card-icon {
    font-size: 3rem;
    opacity: 0.3;
    position: absolute;
    right: 20px;
    top: 20px;
}

/* Mobile: Cards lebih compact */
@media (max-width: 576px) {
    .card-body {
        padding: 1rem;
    }
    
    .card-icon {
        font-size: 2rem;
        right: 15px;
        top: 15px;
    }
    
    .card h2, .card h3 {
        font-size: 1.5rem;
    }
    
    .card h4 {
        font-size: 1.1rem;
    }
}

/* ============================================
   TABLES - Mobile Responsive
   ============================================ */
.table-custom thead {
    background: linear-gradient(135deg, var(--merah) 0%, var(--merah-dark) 100%);
    color: white;
}

.table-custom tbody tr:hover {
    background-color: #FFF5F5;
}

/* Mobile: Horizontal scroll untuk tabel */
.table-responsive {
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table {
        font-size: 0.85rem;
    }
    
    .table th, .table td {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }
    
    /* Tabel dengan scroll hint */
    .table-responsive::after {
        content: '← Geser →';
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: var(--abu);
        padding: 5px;
        background: linear-gradient(90deg, transparent, var(--abu-light), transparent);
    }
}

/* ============================================
   BUTTONS - Touch Friendly
   ============================================ */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    /* Minimum touch target 44x44px */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 10px;
}

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

.btn-merah:hover {
    background: var(--merah-dark);
    border-color: var(--merah-dark);
    color: white;
    transform: translateY(-2px);
}

/* WhatsApp Button */
.btn-whatsapp, .wa-btn {
    background: #25D366;
    border-color: #25D366;
    color: white;
}

.btn-whatsapp:hover, .wa-btn:hover {
    background: #128C7E;
    border-color: #128C7E;
    color: white;
}

/* Button group mobile */
@media (max-width: 576px) {
    .btn-group-sm .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .btn-lg {
        width: 100%;
        padding: 14px 20px;
    }
}

/* ============================================
   FORMS - Mobile Optimized
   ============================================ */
.form-control, .form-select {
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #E9ECEF;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    /* Prevent zoom on iOS */
    font-size: 16px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--merah);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.form-control-lg {
    padding: 14px 18px;
    font-size: 1.1rem;
    border-radius: 10px;
}

.form-label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
}

/* Mobile: Input lebih besar untuk jari */
@media (max-width: 576px) {
    .form-control, .form-select {
        padding: 14px 16px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ============================================
   LOGIN & REGISTER PAGES
   ============================================ */
.login-card, .register-card, .lupa-card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.logo-section {
    background: linear-gradient(135deg, var(--merah) 0%, var(--merah-dark) 100%);
    color: white;
}

/* Mobile: Logo section hidden, full width form */
@media (max-width: 768px) {
    .login-card .row {
        flex-direction: column;
    }
    
    .login-card .logo-section {
        display: none !important;
    }
    
    .login-card .card-body {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 576px) {
    .login-card .card-body,
    .register-card .card-body,
    .lupa-card .card-body {
        padding: 1.5rem 1.25rem;
    }
    
    .login-card h4,
    .register-card h4,
    .lupa-card h4 {
        font-size: 1.25rem;
    }
}

/* ============================================
   POS/KASIR - Touch Optimized
   ============================================ */
.product-card {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    border-radius: var(--radius);
    /* Touch feedback */
    -webkit-tap-highlight-color: rgba(220, 53, 69, 0.2);
}

.product-card:hover, .product-card:active {
    border-color: var(--merah);
    transform: scale(1.02);
    box-shadow: var(--shadow);
}

.cart-item {
    background: var(--abu-light);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px;
    transition: all 0.2s ease;
}

.cart-item:hover {
    background: #E9ECEF;
}

.cart-total {
    background: linear-gradient(135deg, var(--merah) 0%, var(--merah-dark) 100%);
    color: white;
    padding: 18px;
    border-radius: var(--radius);
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
}

/* Mobile: Product grid 2 columns */
@media (max-width: 768px) {
    .product-card {
        margin-bottom: 10px;
    }
    
    .product-card .card-body {
        padding: 10px;
    }
    
    .product-card .card-title {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
    
    .cart-total {
        font-size: 1.25rem;
        padding: 15px;
        position: sticky;
        bottom: 10px;
    }
}

/* ============================================
   ALERTS & BADGES
   ============================================ */
.alert {
    border-radius: var(--radius);
    border: none;
    padding: 1rem 1.25rem;
}

.badge {
    padding: 6px 10px;
    font-weight: 500;
    border-radius: 6px;
}

/* ============================================
   DASHBOARD STATS
   ============================================ */
.stats-card {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

/* Mobile: Stats compact */
@media (max-width: 576px) {
    .stats-card {
        padding: 1rem;
    }
    
    .stats-card h2 {
        font-size: 1.5rem;
    }
    
    .stats-card h6 {
        font-size: 0.8rem;
    }
}

/* ============================================
   ANGGOTA INFO BOX
   ============================================ */
.info-box, .anggota-info {
    background: linear-gradient(135deg, #D1E7DD 0%, #A3CFBB 100%);
    border-radius: var(--radius);
    padding: 1.25rem;
    border-left: 4px solid var(--hijau);
}

/* ============================================
   STEP INDICATOR (Register)
   ============================================ */
.step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    gap: 0;
}

.step {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #E9ECEF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--abu);
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.step.active {
    background: var(--hijau);
    color: white;
    box-shadow: 0 4px 15px rgba(25, 135, 84, 0.4);
}

.step.completed {
    background: var(--hijau);
    color: white;
}

.step-line {
    width: 60px;
    height: 4px;
    background: #E9ECEF;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.step-line.completed {
    background: var(--hijau);
}

/* Mobile: Steps smaller */
@media (max-width: 576px) {
    .step {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    
    .step-line {
        width: 40px;
    }
}

/* ============================================
   MODALS - Mobile Friendly
   ============================================ */
.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-body {
        padding: 1.25rem;
    }
    
    .modal-footer {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        flex: 1 1 100%;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.touch-scroll {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
}

/* Safe area untuk iPhone dengan notch */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================
   LOADING & TRANSITIONS
   ============================================ */
.spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .no-print, .sidebar, .navbar {
        display: none !important;
    }
    
    .col-md-9, .col-lg-10 {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    .struk {
        width: 58mm;
        font-size: 12px;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Uncomment untuk enable dark mode
    :root {
        --abu-light: #1A1A1A;
    }
    
    body {
        background-color: #121212;
        color: #E0E0E0;
    }
    
    .card {
        background: #1E1E1E;
    }
    */
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
/* Focus visible untuk keyboard navigation */
:focus-visible {
    outline: 3px solid var(--merah);
    outline-offset: 2px;
}

/* Reduced motion untuk user yang sensitif */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   CUSTOM SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #F1F1F1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #C1C1C1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #A1A1A1;
}

/* Mobile: Hide scrollbar tapi tetap bisa scroll */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}
