@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

:root {
    --primary: #d18400;
    --primary-rgb: 209, 132, 0;
    --primary-hover: #b87300;
    --primary-light: #fef3c7;
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --card-shadow-hover: 0 20px 30px -10px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Web Top Navbar
   ========================================================================== */
.web-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.web-navbar-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.web-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
}

.web-brand-logos {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.web-brand-logos img.logo-pemkot {
    height: 42px;
    width: auto;
    object-fit: contain;
}

.web-brand-logos img.logo-dispersip {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.web-brand-text {
    display: flex;
    flex-direction: column;
}

.web-brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.web-brand-title .badge-online {
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    text-transform: uppercase;
}

.web-brand-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Nav Links */
.web-nav-menu {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    list-style: none;
}

.web-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
}

.web-nav-link:hover {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.06);
}

.web-nav-link.active {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    font-weight: 700;
}

.web-nav-btn-admin {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    color: white;
    background: var(--primary);
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.25);
}

.web-nav-btn-admin:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(var(--primary-rgb), 0.35);
}

.lang-badge {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    background: #ffffff;
}

.lang-badge:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ==========================================================================
   Page Main Content
   ========================================================================== */
.web-main {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Hero Title Section */
.hero-section {
    text-align: center;
    margin-bottom: 2rem;
}

.hero-title {
    font-size: 2.3rem;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.5px;
    margin-bottom: 0.4rem;
}

.hero-title span {
    color: var(--primary);
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Form Container Split */
.guestbook-wrapper {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 2rem;
    align-items: start;
}

.form-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 2.2rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    position: relative;
}

.card-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 1.8rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header-title i {
    color: var(--primary);
    font-size: 1.4rem;
}

/* Form Grid */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark);
    background: #ffffff;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.form-group.has-error .form-control {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.error-message {
    color: #ef4444;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.35rem;
    display: none;
}

.form-group.has-error .error-message {
    display: block;
}

/* Interactive Chips */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.3rem;
}

.purpose-chip, .gender-chip, .age-chip {
    padding: 0.65rem 1.1rem;
    background: #f1f5f9;
    color: #334155;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.purpose-chip:hover, .gender-chip:hover, .age-chip:hover {
    background: #e2e8f0;
    color: var(--text-dark);
    transform: translateY(-1px);
}

.purpose-chip.active, .gender-chip.active, .age-chip.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.3);
}

.gender-chips-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.age-chips-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
}

/* Submit Button */
.btn-submit-guestbook {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    transition: all 0.25s ease;
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.3);
    margin-top: 0.8rem;
}

.btn-submit-guestbook:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(var(--primary-rgb), 0.4);
}

.btn-submit-guestbook:active {
    transform: translateY(0);
}

.spinner {
    display: none;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* QR Side Card */
.qr-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 2.2rem 1.8rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: sticky;
    top: 90px;
}

.qr-icon-bubble {
    width: 60px;
    height: 60px;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.qr-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 0.4rem;
}

.qr-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 1.5rem;
}

.qr-box {
    background: #ffffff;
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.qr-box img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    display: block;
}

.qr-url-box {
    font-size: 0.82rem;
    color: var(--text-muted);
    background: #f8fafc;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-color);
    width: 100%;
    word-break: break-all;
}

.qr-url-box strong {
    color: var(--primary);
    font-size: 0.88rem;
}

/* Success Modal Overlay */
.success-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    padding: 1.5rem;
}

.success-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.success-modal-content {
    background: #ffffff;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-modal.active .success-modal-content {
    transform: scale(1);
}

.success-modal-icon {
    width: 80px;
    height: 80px;
    background: #dcfce7;
    color: #16a34a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem auto;
}

/* ==========================================================================
   Web Footer
   ========================================================================== */
.web-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.web-footer strong {
    color: var(--text-dark);
}

/* ==========================================================================
   Admin Portal Styles
   ========================================================================== */
.admin-container {
    width: 100%;
}

.admin-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-title-area h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.5px;
}

.admin-title-area p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.stat-icon-wrapper {
    width: 55px;
    height: 55px;
    border-radius: 12px;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.stat-info h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info .stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.2;
}

/* Chart Container */
.chart-card {
    background: #ffffff;
    padding: 1.8rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* Filter Bar */
.filter-bar {
    background: #ffffff;
    padding: 1.2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.filter-select, .filter-date {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    background: #ffffff;
}

.date-range-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.date-input-group {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.date-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.date-separator {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.btn-reset-filter {
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-sm);
    background: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    transition: 0.2s;
    text-decoration: none;
}

.btn-reset-filter:hover {
    background: #e2e8f0;
    color: var(--text-dark);
}

.btn-filter {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
}

.btn-filter:hover {
    background: var(--primary-hover);
}

.btn-export-excel {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    background: #10b981;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    transition: 0.2s;
}

.btn-export-excel:hover {
    background: #059669;
}

/* Data Table */
.table-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.92rem;
}

.data-table thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-dark);
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.badge-tag {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}

/* Pagination */
.pagination-wrapper {
    padding: 1.2rem;
    display: flex;
    justify-content: center;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   Iframe / Seamless Embed Mode
   ========================================================================== */
html.in-iframe {
    background: transparent !important;
}

html.in-iframe body {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
}

html.in-iframe .web-navbar,
html.in-iframe .web-footer {
    display: none !important;
}

html.in-iframe .web-main {
    max-width: 100% !important;
    padding: 1rem !important;
}

html.in-iframe .guestbook-wrapper {
    gap: 1.5rem;
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
    .guestbook-wrapper {
        grid-template-columns: 1fr;
    }
    .qr-card {
        position: static;
    }
    .web-navbar-container {
        flex-direction: column;
        align-items: flex-start;
    }
    .web-nav-menu {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
    .hero-title {
        font-size: 1.8rem;
    }
    .form-card {
        padding: 1.5rem;
    }
}
