:root {
    --primary-blue: #003366;
    --secondary-blue: #0056b3;
    --accent-gold: #B8860B;
    --bg-color: #f4f6f9;
    --text-main: #333333;
    --text-muted: #6c757d;
    --white: #ffffff;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --border-color: #e0e0e0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', 'Prompt', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    padding: 20px 10px;
}

.container {
    width: 100%;
    max-width: 480px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    padding: 25px 20px;
    overflow: hidden;
}

.header {
    text-align: center;
    color: var(--primary-blue);
    font-size: 24px;
    margin-bottom: 5px;
    font-weight: bold;
}

.sub-header {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 25px;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
    text-align: left;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    background-color: #f8f9fa;
    transition: border-color 0.3s, box-shadow 0.3s;
    resize: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--secondary-blue);
    background-color: var(--white);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

input:disabled, select:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.7;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

/* Buttons */
button {
    width: 100%;
    background-color: var(--primary-blue);
    color: white;
    border: none;
    padding: 14px;
    font-size: 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.2s ease-in-out;
}

.back-btn {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    margin-top: 10px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    font-weight: normal;
    width: auto;
    margin-top: 0;
}

.btn-save { background-color: var(--success); }
.btn-approve { background-color: var(--success); }
.btn-reject { background-color: var(--danger); }
.btn-view { background-color: var(--secondary-blue); }

.status-msg {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    font-weight: bold;
}

/* Dashboard Cards */
.profile-section {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

#pictureUrl {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 15px;
    object-fit: cover;
    border: 2px solid var(--white);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: none;
}

#displayName {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-blue);
}

.user-info-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}
.info-row:last-child { margin-bottom: 0; }
.info-label { color: var(--text-muted); }
.info-value { font-weight: 600; color: var(--text-main); }

/* Apps Grid */
.analytics-header {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-blue);
    margin-bottom: 15px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.app-item {
    text-align: center;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s;
}

.app-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    margin-bottom: 8px;
    color: white;
}

.bg-match { background: linear-gradient(135deg, #FF6B6B, #FF8E53); }
.bg-market { background: linear-gradient(135deg, #4facfe, #00f2fe); }

.app-label {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

/* Dashboard Stats */
.analytics-card {
    background: transparent;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 20px;
}

.dashboard-header-card {
    background: linear-gradient(135deg, #003366, #0056b3);
    color: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    text-align: center;
}
.dashboard-header-card h3 { margin: 0 0 5px 0; font-size: 16px; }
.dashboard-subtitle { font-size: 12px; opacity: 0.85; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card, .stat-box {
    background: var(--white);
    padding: 15px 10px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #eaeaea;
    transition: all 0.2s;
}

.stat-num {
    font-size: 24px;
    font-weight: 900;
    color: var(--primary-blue);
    margin-bottom: 2px;
    line-height: 1;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* Coins and Topup */
.gold-coin {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: #FFD700;
    border-radius: 50%;
    border: 2px solid #DAA520;
    box-shadow: inset 0 0 3px rgba(255,255,255,0.8), 0 1px 2px rgba(0,0,0,0.2);
    vertical-align: middle;
    position: relative;
}

.gold-coin::after {
    content: "P";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
    font-weight: bold;
    color: #DAA520;
}

.package-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.package-item {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: white;
}

.package-item.selected {
    border-color: var(--secondary-blue);
    background-color: #f0f7ff;
}

.pkg-title {
    font-weight: bold;
    font-size: 16px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pkg-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.pkg-price {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-blue);
}

/* Admin Styles */
.user-card {
    background: white;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.user-detail {
    font-size: 12px;
    color: var(--text-muted);
    margin: 5px 0 10px 0;
}

.action-row {
    display: flex;
    gap: 8px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none; 
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
}

.tab.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.admin-user-card {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.admin-user-card.banned {
    border-color: #ffcccc;
    background: #fffafa;
    opacity: 0.8;
}
.admin-user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #eee;
}
.admin-user-name {
    font-weight: bold;
    font-size: 15px;
    color: #333;
}
.admin-user-body {
    font-size: 13px;
    color: #555;
    margin-bottom: 15px;
}
.admin-user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
}
.quota-control label {
    font-size: 12px;
    font-weight: bold;
    color: #666;
    margin-bottom: 3px;
    display: block;
}
.quota-control input {
    width: 60px;
    padding: 4px;
    font-size: 13px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Match UI */
.my-requests-box {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}
.req-item {
    background: white;
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
}
.req-item.incoming {
    border-left: 4px solid var(--secondary-blue);
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}
.badge-searching { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.badge-matched { background-color: #d4edda; color: #155724; }

.warning-box {
    background-color: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #ffeeba;
    margin-bottom: 15px;
    font-size: 13px;
}
.quota-free-box {
    background-color: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #c3e6cb;
    margin-bottom: 15px;
    font-size: 13px;
    text-align: center;
}
.quota-full-box {
    background-color: #f8d7da;
    color: #721c24;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
    margin-bottom: 15px;
    text-align: center;
}
.quota-full-box h4 { margin-top:0; margin-bottom: 5px; }

.form-section-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-blue);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.btn-topup-green {
    display: inline-block;
    background-color: var(--success);
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 6px;
    font-weight: bold;
    margin-top: 10px;
}

/* Kebab Menu */
.req-dropdown {
    position: absolute;
    right: 10px;
    top: 10px;
}
.req-kebab-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #888;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    margin-top: 0;
    width: auto;
}
.req-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 25px;
    background-color: #fff;
    min-width: 140px;
    box-shadow: 0px 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    border-radius: 8px;
    border: 1px solid #eee;
    overflow: hidden;
}
.req-dropdown-content a {
    color: #333;
    padding: 12px 15px;
    text-decoration: none;
    display: block;
    font-size: 13px;
    border-bottom: 1px solid #f9f9f9;
}
.danger-text { color: var(--danger) !important; }
.show-dropdown { display: block !important; }

/* Handshake Match Cards */
.match-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.perfect-match { border: 2px solid var(--success); background-color: #f8fff9; }
.good-match { border: 2px solid #17a2b8; }
.score-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    margin-bottom: 10px;
}
.score-100 { background-color: var(--success); }
.score-50 { background-color: #17a2b8; }
.score-10 { background-color: #6c757d; }
.partner-info {
    font-size: 14px;
    color: #333;
    margin-bottom: 15px;
    line-height: 1.5;
}
.reveal-box {
    background-color: #e9ecef;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 15px;
    border-left: 4px solid var(--success);
}
.explore-box {
    background: #f8f9fa;
    border: 1px dashed #adb5bd;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}
.explore-box h4 {
    margin-top: 0;
    color: var(--primary-blue);
    font-size: 15px;
    margin-bottom: 5px;
}

/* Loading Overlay */
#loadingOverlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.9);
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: var(--primary-blue);
}

/* Premium Loading (Admin) */
.premium-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--primary-blue);
    animation: pulseFade 1.5s infinite alternate ease-in-out;
}
@keyframes pulseFade {
    0% { opacity: 0.6; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}
.premium-loading .icon {
    font-size: 36px;
    margin-bottom: 12px;
}
.premium-loading .text {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Autocomplete Suggestion */
#stationSuggestions {
    position: absolute;
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.suggestion-item {
    padding: 10px 15px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
}

/* Hover Effects */
button:hover, 
.btn-save:hover, 
.btn-accept:hover, 
.btn-refresh:hover, 
.back-btn:hover,
.app-item:hover,
.stat-card:hover,
.stat-box:hover {
    filter: brightness(1.05) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 12px rgba(0,0,0,0.08) !important;
    transition: all 0.2s ease-in-out;
}

button:active, 
.btn-save:active, 
.btn-accept:active, 
.btn-refresh:active, 
.back-btn:active,
.app-item:active {
    transform: translateY(1px) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
    filter: brightness(0.95) !important;
    transition: all 0.1s;
}

.req-kebab-btn:hover {
    filter: none !important;
    transform: none !important;
    box-shadow: none !important;
    background-color: #f0f0f0 !important;
    border-radius: 50% !important;
}

/* =========================================
   UI/UX Polish: Smooth Transitions & Premium UI
========================================= */

/* 1. เอฟเฟกต์เวลาโหลดเนื้อหาและเปลี่ยนแท็บ */
@keyframes fadeAndSlideUp {
    0% { opacity: 0; transform: translateY(15px); }
    100% { opacity: 1; transform: translateY(0); }
}

.tab-content.active, 
.req-item, 
.match-card, 
.admin-user-card,
.explore-box {
    animation: fadeAndSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 2. ปรับความลื่นไหลของปุ่มเวลา Hover และ Active */
button, .btn-save, .action-btn, .tab, .app-item {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 3. ยกระดับหน้าตา SweetAlert Popup ให้เป็นสไตล์ SuperApp */
div:where(.swal2-container) div:where(.swal2-popup) {
    border-radius: 16px !important;
    font-family: 'Sarabun', 'Prompt', sans-serif !important;
    padding: 1.5em;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
}

div:where(.swal2-container) button:where(.swal2-styled) {
    border-radius: 8px !important;
    font-weight: bold !important;
    transition: all 0.2s !important;
}

div:where(.swal2-container) h2:where(.swal2-title) {
    font-size: 20px !important;
    color: var(--primary-blue) !important;
}