/* ============================================
   Kantin TJKT - Shared Styles
   Mobile-First Design System
   ============================================ */

/* CSS Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --dark-color: #333;
    --light-bg: rgba(255, 255, 255, 0.95);
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 20px 40px rgba(0, 0, 0, 0.1);
    --border-radius: 15px;
    --border-radius-lg: 20px;
    --border-radius-pill: 25px;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --transition: all 0.3s ease;
}

/* Global Reset & Base */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--primary-gradient);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 20px);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container Styles */
.container, .container-fluid {
    background: var(--light-bg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-medium);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    color: var(--dark-color);
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.5rem;
}

/* Button Base Styles */
.btn {
    border-radius: var(--border-radius-pill);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition);
    border: none;
    position: relative;
    overflow: hidden;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transition: var(--transition);
    transform: translate(-50%, -50%);
}

.btn:hover::before,
.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:active {
    transform: scale(0.98);
}

/* Button Variants */
.btn-primary {
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(45deg, #0056b3, #004085);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.btn-success {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn-success:hover {
    background: linear-gradient(45deg, #20c997, #17a2b8);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.btn-danger {
    background: linear-gradient(45deg, #dc3545, #c82333);
    color: white;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(45deg, #c82333, #a71e2a);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
}

.btn-warning {
    background: linear-gradient(45deg, #ffc107, #e0a800);
    color: #333;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.btn-warning:hover {
    background: linear-gradient(45deg, #e0a800, #d39e00);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.4);
}

.btn-info {
    background: linear-gradient(45deg, #17a2b8, #138496);
    color: white;
    box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3);
}

.btn-info:hover {
    background: linear-gradient(45deg, #138496, #117a8b);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(23, 162, 184, 0.4);
}

/* Form Styles */
.form-control {
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 14px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.9);
    min-height: 48px;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    background: #fff;
    outline: none;
}

.form-group label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 8px;
    display: block;
}

/* Table Styles */
.table-responsive {
    border-radius: var(--border-radius);
    overflow-x: auto;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
}

.table {
    margin-bottom: 0;
    background: white;
}

.table thead th {
    background: var(--primary-gradient);
    color: white;
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

.table td {
    padding: 10px 8px;
    vertical-align: middle;
    border-color: #e9ecef;
    font-size: 0.85rem;
}

/* Product Image */
.product-image {
    width: 100%;
    height: auto;
    max-width: 70px;
    border-radius: 10px;
    border: 2px solid #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    object-fit: cover;
    cursor: pointer;
    transition: var(--transition);
}

.product-image:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* Lightbox */
#lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

#lightbox-overlay img {
    max-width: 95%;
    max-height: 90%;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

#lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 32px;
    color: white;
    background: rgba(220, 53, 69, 0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-close:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.1);
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #666;
    font-size: 0.7rem;
    padding: 8px 12px;
    min-width: 60px;
    transition: var(--transition);
}

.bottom-nav a i {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.bottom-nav a.active,
.bottom-nav a:hover {
    color: var(--primary-color);
}

.bottom-nav a.active i,
.bottom-nav a:hover i {
    transform: scale(1.1);
}

/* Cart Info */
.cart-info {
    background: var(--primary-gradient);
    color: white;
    padding: 15px;
    border-radius: var(--border-radius-lg);
    text-align: center;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    position: sticky;
    top: 10px;
    z-index: 100;
    margin-bottom: 15px;
}

.cart-info h4 {
    font-weight: 700;
    margin-bottom: 10px;
    font-size: 1.2rem;
    color: white;
}

.cart-info p {
    margin: 5px 0;
    font-size: 1rem;
}

.cart-info span {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Product Card (for index.php) */
.product-card {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: none;
    border-radius: var(--border-radius-lg);
    padding: 15px;
    text-align: center;
    margin-bottom: 15px;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s;
}

.product-card:hover::before {
    left: 100%;
}

.product-card:active {
    transform: scale(0.98);
}

.product-card .product-image {
    max-width: 100px;
    height: 100px;
}

.product-name {
    font-weight: 700;
    margin-top: 10px;
    text-transform: uppercase;
    color: var(--dark-color);
    font-size: 0.85rem;
    line-height: 1.3;
}

.product-price {
    color: var(--success-color);
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 6px;
}

.product-counter {
    position: absolute;
    top: 8px;
    left: 8px;
    background: linear-gradient(45deg, #ff4757, #ff3742);
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4);
    animation: pulse 2s infinite;
    z-index: 10;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(40, 167, 69, 0.5);
}

.fab:disabled {
    background: #6c757d;
    box-shadow: 0 3px 10px rgba(108, 117, 125, 0.3);
    cursor: not-allowed;
    opacity: 0.7;
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 70px;
    left: 10px;
    right: 10px;
    background: white;
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    align-items: center;
    gap: 15px;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pwa-install-banner img {
    width: 48px;
    height: 48px;
    border-radius: 10px;
}

.pwa-install-banner .content {
    flex: 1;
}

.pwa-install-banner .title {
    font-weight: 700;
    color: var(--dark-color);
}

.pwa-install-banner .subtitle {
    font-size: 0.8rem;
    color: #666;
}

.pwa-install-banner .btn-install {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius-pill);
    font-weight: 600;
    cursor: pointer;
}

.pwa-install-banner .btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 5px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: 10px;
}

/* ============================================
   Tablet & Desktop Styles
   ============================================ */
@media (min-width: 768px) {
    body {
        padding-bottom: 30px;
    }

    .container, .container-fluid {
        margin: 20px auto;
        padding: 30px;
    }

    h2 {
        font-size: 2rem;
        margin-bottom: 30px;
    }

    .table thead th {
        padding: 15px 10px;
        font-size: 0.9rem;
    }

    .table td {
        padding: 12px 10px;
        font-size: 0.9rem;
    }

    .product-image {
        max-width: 80px;
    }

    .product-card {
        padding: 20px;
    }

    .product-card .product-image {
        max-width: 120px;
        height: 120px;
    }

    .product-name {
        font-size: 1rem;
    }

    .product-price {
        font-size: 1.2rem;
    }

    .bottom-nav {
        display: none;
    }

    .fab {
        bottom: 30px;
        right: 30px;
        width: 64px;
        height: 64px;
        font-size: 1.8rem;
    }

    /* Desktop Top Navigation */
    .top-nav {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        margin-bottom: 20px;
    }

    .top-nav .btn {
        flex: 0 0 auto;
    }
}

@media (min-width: 1200px) {
    .product-card .product-image {
        max-width: 140px;
        height: 140px;
    }
}

/* Animation for table rows */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.table tbody tr {
    animation: fadeInUp 0.4s ease forwards;
}

.table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.table tbody tr:nth-child(2) { animation-delay: 0.1s; }
.table tbody tr:nth-child(3) { animation-delay: 0.15s; }
.table tbody tr:nth-child(4) { animation-delay: 0.2s; }
.table tbody tr:nth-child(5) { animation-delay: 0.25s; }

/* Loading States */
.loading {
    pointer-events: none;
    opacity: 0.7;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--danger-color);
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 9999;
    display: none;
}

.offline-indicator.show {
    display: block;
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
    .bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    
    body {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}
