/* ==========================================================================
   PANELTIKDIWA — Admin Control Panel & Cute Liquid Glass Dashboard
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700;800&display=swap');

:root {
    --pink-primary: #2557e8;
    --pink-bright: #3e86ff;
    --pink-soft: #e6f0ff;
    --pink-pastel: #f0f6ff;
    --pink-border: #c5dcff;
    --bg-main: #f4fbfe;
    --text-main: #231920;
    --text-muted: #7B6B74;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-pill: 999px;
}

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

body {
    font-family: 'Prompt', sans-serif;
    background: radial-gradient(circle at top right, #dcf2fa 0%, #f4fbfe 45%, #e9f7fc 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.admin-sidebar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(142, 197, 255, 0.6);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.admin-sidebar > div:first-child {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 8px 16px;
    border-bottom: 1px solid #dcecf5;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.mobile-menu-toggle,
.mobile-sidebar-close {
    display: none;
}

.admin-sidebar-overlay {
    display: none;
}

.sidebar-footer-actions {
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid #dcecf5;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(62, 134, 255, 0.28) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(62, 134, 255, 0.25);
    border-radius: 999px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(62, 134, 255, 0.5);
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 16px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.menu-btn:hover {
    background: var(--pink-pastel);
    color: var(--pink-primary);
}

.menu-btn.active {
    background: linear-gradient(135deg, #3e86ff 0%, #1b46c7 100%);
    color: #FFFFFF;
    box-shadow: 0 6px 18px rgba(37, 105, 255, 0.25);
}

/* ==================== MAIN CONTENT ==================== */
.admin-main {
    padding: 26px 32px;
    max-width: 1440px;
    width: 100%;
    min-width: 0;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.top-bar-title {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.25;
}

.top-bar-sub {
    font-size: 0.86rem;
    color: var(--text-muted);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dash-two-col-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 22px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-glass-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    border: 1.5px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 28px rgba(37, 105, 255, 0.08);
    border-radius: var(--radius-xl);
    padding: 20px;
}

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

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 4px;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1.5px solid rgba(142, 197, 255, 0.55);
    box-shadow: 0 12px 34px rgba(37, 105, 255, 0.07);
    border-radius: var(--radius-xl);
    padding: 22px;
    margin-bottom: 24px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.panel-title {
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== TABLES & FORMS ==================== */
.table-responsive,
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.admin-table,
.table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.table-wrap table th {
    text-align: left;
    padding: 12px 14px;
    background: var(--pink-pastel);
    color: var(--pink-primary);
    font-weight: 700;
    white-space: nowrap;
}

.admin-table td,
.table-wrap table td {
    padding: 12px 14px;
    border-bottom: 1px solid #F4E8EE;
    vertical-align: middle;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.form-input,
.form-select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1.5px solid #E8DCE2;
    background: #FFFFFF;
    font-family: inherit;
    font-size: 0.93rem;
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23C2185B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--pink-primary);
    box-shadow: 0 0 0 3px rgba(37, 105, 255, 0.12);
}

.btn-pink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    border: none;
    background: linear-gradient(135deg, #3e86ff 0%, #1b46c7 100%);
    color: #FFFFFF;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(37, 105, 255, 0.25);
    transition: all 0.2s;
}

.btn-pink:hover {
    transform: translateY(-1px);
}

.btn-soft {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 10px;
    border: 1px solid var(--pink-border);
    background: var(--pink-pastel);
    color: var(--pink-primary);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
}

.badge-active { background: #DCFCE7; color: #15803D; }
.badge-spare  { background: #FEF3C7; color: #B45309; }
.badge-error  { background: #FFE4E6; color: #E11D48; }

/* ==================== LIQUID GLASS MODALS & TOASTS ==================== */
.liquid-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(35, 18, 28, 0.42);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.liquid-overlay.open {
    opacity: 1;
    visibility: visible;
}

.liquid-modal {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 28px;
    background: linear-gradient(160deg, rgba(255,255,255,0.94), rgba(255,243,248,0.92));
    backdrop-filter: blur(26px);
    border: 1.5px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 24px 60px rgba(37, 105, 255, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.95);
    padding: 26px 24px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.liquid-overlay.open .liquid-modal {
    transform: scale(1);
}

.liquid-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.liquid-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    border: 1.5px solid rgba(142, 197, 255, 0.8);
    box-shadow: 0 12px 30px rgba(37, 105, 255, 0.2);
}

/* ==================== RESPONSIVE BREAKPOINTS (MOBILE / TABLET / DESKTOP) ==================== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dash-two-col-grid {
        grid-template-columns: 1fr;
    }
    .admin-layout {
        grid-template-columns: 1fr;
    }

    /* ปุ่มแฮมเบอร์เกอร์เปิดเมนูบน Mobile & Tablet */
    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border-radius: 14px;
        border: 1.5px solid var(--pink-border);
        background: #FFFFFF;
        color: var(--pink-primary);
        font-size: 1.15rem;
        cursor: pointer;
        flex-shrink: 0;
        box-shadow: 0 4px 12px rgba(37, 105, 255, 0.1);
    }

    .mobile-sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: 1px solid var(--pink-border);
        background: var(--pink-pastel);
        color: var(--pink-primary);
        font-size: 1rem;
        cursor: pointer;
    }

    /* Slide-in Liquid Glass Drawer สำหรับ Sidebar บนมือถือ */
    .admin-sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1100;
        background: rgba(35, 18, 28, 0.42);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        opacity: 0;
        visibility: hidden;
        transition: all 0.25s ease;
    }

    .admin-sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 84vw;
        height: 100vh;
        z-index: 1150;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        box-shadow: 12px 0 36px rgba(37, 105, 255, 0.18);
        padding: 20px 16px;
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-menu {
        flex-direction: column;
        overflow-x: visible;
        gap: 6px;
    }

    .menu-btn {
        width: 100%;
        white-space: nowrap;
        padding: 11px 14px;
    }
}

@media (max-width: 640px) {
    .admin-main {
        padding: 14px 12px 28px;
    }
    .top-bar {
        position: sticky;
        top: 0;
        z-index: 900;
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        margin: -14px -12px 16px;
        padding: 12px 14px;
        border-bottom: 1px solid rgba(142, 197, 255, 0.55);
        gap: 10px;
    }
    .top-bar-title {
        font-size: 1.08rem;
    }
    .top-bar-sub {
        font-size: 0.72rem;
        display: none;
    }
    .top-bar-actions {
        width: 100%;
        justify-content: space-between;
    }
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 16px;
    }
    .stat-glass-card {
        padding: 14px 12px;
        border-radius: 18px;
    }
    .stat-label {
        font-size: 0.76rem;
    }
    .stat-value {
        font-size: 1.32rem;
    }
    .glass-panel {
        padding: 16px 14px;
        border-radius: 20px;
        margin-bottom: 16px;
    }
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .panel-header .btn-pink {
        width: 100%;
    }
    .panel-title {
        font-size: 1.04rem;
    }
    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .admin-table th,
    .admin-table td,
    .table-wrap table th,
    .table-wrap table td {
        padding: 10px 10px;
        font-size: 0.82rem;
    }
    .liquid-modal {
        padding: 20px 16px;
        border-radius: 22px;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
