@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Outfit:wght@400;600;800&display=swap');

:root {
    --primary: #2563eb;
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --primary-light: #eff6ff;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
}

/* Navigation Menu */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
}

/* Main Layout */
.container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--text-muted);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.875rem;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-body);
    border-color: var(--secondary);
}

/* Professional Coupon Style */
.coupon-container {
    max-width: 450px;
    margin: 2rem auto;
}

.coupon-pro {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    width: 9.5cm;
    min-height: 9cm; /* Gunakan min-height agar bisa melar */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.coupon-footer {
    padding: 1rem 1.2rem;
    background: rgba(248, 250, 252, 0.4);
    border-top: 1px solid #e2e8f0;
    font-size: 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem; /* Tambahkan gap agar tidak menempel */
    position: relative;
    z-index: 1;
    margin-top: auto;
}

.coupon-note {
    color: var(--text-muted);
    line-height: 1.3;
    max-width: 65%;
}

.coupon-signature {
    text-align: center;
    min-width: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.coupon-signature img {
    max-height: 35px;
    max-width: 90px;
    object-fit: contain;
    margin: 0.1rem 0;
}

.coupon-pro-header {
    text-align: center;
    padding: 1rem 1rem 0.8rem 1rem;
    border-bottom: 2px dashed rgba(0,0,0,0.05);
    position: relative;
}

.coupon-pro-header img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin: 0 auto 0.5rem auto !important;
    display: block !important;
}

.coupon-pro-header h3 {
    font-family: 'Outfit', sans-serif !important;
    font-size: 1.5rem !important;
    font-weight: 900 !important;
    margin: 0px 0 4px 0 !important;
    line-height: 1.1 !important;
    letter-spacing: -0.5px !important;
    text-transform: uppercase;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #2563eb; /* Fallback for browsers that don't support clip-text */
    display: inline-block;
}

.coupon-pro-header .coupon-label {
    font-size: 0.6rem !important;
    letter-spacing: 4px !important;
    color: var(--secondary) !important;
    font-weight: 800 !important;
    text-transform: uppercase;
    margin-bottom: 4px !important;
    display: inline-block;
    position: relative;
    opacity: 0.8;
}

.coupon-pro-header .coupon-label::before,
.coupon-pro-header .coupon-label::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 15px;
    height: 1px;
    background: var(--secondary);
    opacity: 0.4; /* Perjelas garis */
}

.coupon-pro-header .coupon-label::before { right: 105%; }
.coupon-pro-header .coupon-label::after { left: 105%; }

.coupon-pro-header p {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    color: var(--secondary) !important;
    margin: 0 !important;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.coupon-pro-header .event-date {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    color: var(--text-main) !important;
    margin-top: 6px !important; /* Beri sedikit ruang agar tidak mepet */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.coupon-pro-body {
    padding: 0.5rem 1rem 0.2rem 1rem;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.coupon-label {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.coupon-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1.25rem;
}

.qr-wrapper {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 12px;
    display: inline-block;
    margin: 1rem 0;
    border: 1px solid #e2e8f0;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 1rem;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-valid { background: #dcfce7; color: #166534; }
.status-used { background: #fee2e2; color: #991b1b; }

/* Grid for Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .nav-menu { display: none; }
}

@media print {
    body { background: white; }
    .navbar, .no-print { display: none; }
    .container { margin: 0; padding: 0; max-width: 100%; }
}

/* QR Scanner Overrides */
#reader {
    border: none !important;
    background: #ffffff;
    border-radius: 24px;
    overflow: hidden;
    width: 100% !important;
    max-width: 450px;
    margin: 0 auto !important;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

#reader video {
    object-fit: cover !important;
    border-radius: 24px;
    width: 100% !important;
    aspect-ratio: 1/1;
}

/* Sembunyikan elemen sampah dari library */
#reader __dashboard, 
#reader __status_span, 
#reader span {
    display: none !important;
}

#reader img {
    display: none !important;
}

#reader button {
    background-color: var(--primary) !important;
    color: white !important;
    border: none !important;
    padding: 1rem 2rem !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer !important;
    margin: 20px auto !important;
    display: block !important;
    width: 80% !important;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3) !important;
}

#reader select {
    padding: 0.8rem !important;
    border-radius: 12px !important;
    border: 2px solid #f1f5f9 !important;
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-family: inherit !important;
    width: 90% !important;
    margin: 15px auto !important;
    display: block !important;
    font-weight: 600 !important;
    cursor: pointer;
}

/* --- RESPONSIVE DESIGN --- */
@media screen and (max-width: 768px) {
    .navbar {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .nav-container {
        padding: 0.8rem 1.5rem;
        flex-direction: row; /* Keep brand and toggle on same line */
        justify-content: space-between;
        align-items: center;
    }

    /* Hamburger Button */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 30px;
        height: 20px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1001;
    }

    .mobile-menu-toggle span {
        width: 100%;
        height: 3px;
        background: var(--text-main);
        border-radius: 10px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-menu-toggle.active span:nth-child(1) {
        transform: translateY(8.5px) rotate(45deg);
    }
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: translateY(-8.5px) rotate(-45deg);
    }

    /* Slide-out Menu */
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: white;
        display: flex !important;
        flex-direction: column;
        padding: 80px 2rem 2rem 2rem;
        gap: 0.5rem;
        box-shadow: -10px 0 30px rgba(0,0,0,0.1);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        overflow-y: auto;
        visibility: hidden;
    }

    .nav-menu.active {
        right: 0 !important;
        visibility: visible;
    }

    .nav-link {
        width: 100%;
        padding: 1rem 1.5rem;
        border-radius: 12px;
        font-size: 1rem;
    }

    .nav-link.active {
        background: var(--bg-body);
        color: var(--primary);
    }

    .container {
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    /* Responsive Table */
    .table-container {
        margin: 0 -1rem;
        border-radius: 0;
        overflow-x: auto;
    }

    .data-table th, .data-table td {
        padding: 0.8rem 1rem;
        font-size: 0.85rem;
    }

    /* Settings Mobile */
    .preview-logo { max-width: 80px; }
    .preview-bg { width: 100%; height: auto; }

    /* Fix for Print Grid on Mobile View (Screen Only) */
    .print-grid {
        grid-template-columns: 1fr !important;
    }
}

@media screen and (max-width: 480px) {
    .nav-brand {
        font-size: 1.1rem;
    }
    
    .card {
        padding: 1.2rem;
    }

    .btn {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }
}
