/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
    /* Fonts */
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Theme Colors (Modern Slate Dark Mode) */
    --color-bg-base: #0b0f19;
    --color-bg-surface: rgba(17, 24, 39, 0.75);
    --color-bg-card: rgba(30, 41, 59, 0.45);
    --color-border: rgba(255, 255, 255, 0.06);
    --color-border-hover: rgba(255, 255, 255, 0.12);

    --color-text-primary: #f3f4f6;
    --color-text-secondary: #9ca3af;
    --color-text-muted: #6b7280;

    /* Accent & Semantic Colors */
    --color-primary-hsl: 224, 86%, 53%;
    --color-primary: hsl(var(--color-primary-hsl));
    --color-primary-glow: rgba(59, 130, 246, 0.15);

    --color-success-hsl: 142, 71%, 45%;
    --color-success: hsl(var(--color-success-hsl));
    --color-success-glow: rgba(16, 185, 129, 0.15);

    --color-warning-hsl: 38, 92%, 50%;
    --color-warning: hsl(var(--color-warning-hsl));

    --color-danger-hsl: 350, 89%, 60%;
    --color-danger: hsl(var(--color-danger-hsl));
    --color-danger-glow: rgba(244, 63, 94, 0.15);

    --color-purple-hsl: 263, 70%, 50%;
    --color-purple: hsl(var(--color-purple-hsl));
    --color-purple-glow: rgba(139, 92, 246, 0.15);

    /* Animation Constants */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & GLOBAL RESETS
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg-base);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
    /* Soft ambient background glow */
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.05) 0px, transparent 50%);
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), hsl(240, 80%, 60%));
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--color-text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   LOADING OVERLAY
   ========================================================================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-container {
    text-align: center;
}

.pulse-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 20px var(--color-primary);
    animation: pulseGlow 1.5s ease-in-out infinite;
}

.loading-text {
    font-family: var(--font-heading);
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

@keyframes pulseGlow {

    0%,
    100% {
        transform: scale(0.85);
        opacity: 0.5;
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
        box-shadow: 0 0 30px rgba(59, 130, 246, 0.8);
    }
}

/* ==========================================================================
   LOGIN CARD SCREEN
   ========================================================================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    background: var(--color-bg-surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--color-border);
    border-radius: 24px;
    padding: 3.5rem 2.5rem;
    max-width: 460px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUpFade 0.6s var(--transition-slow);
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 9999px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
}

.brand-badge .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #60a5fa;
    animation: flash 2s infinite;
}

.login-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 2.5rem;
}

.btn-login {
    width: 100%;
    padding: 1rem;
    font-size: 1.05rem;
}

.login-footer {
    margin-top: 3rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* ==========================================================================
   DASHBOARD SCREEN & NAVIGATION
   ========================================================================== */
.dashboard-container {
    animation: fadeIn 0.4s var(--transition-normal);
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.5rem;
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 40%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-user-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 1.5rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-purple), var(--color-primary));
    color: #ffffff;
    font-family: var(--font-heading);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.2);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.btn-logout {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* ==========================================================================
   DASHBOARD CONTENT
   ========================================================================== */
.dashboard-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

/* Page Header & Stats */
.dashboard-header-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

@media (min-width: 768px) {
    .dashboard-header-section {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-end;
    }
}

.page-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.35rem;
}

.page-subtitle {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

/* Stats Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(140px, 180px));
    gap: 1rem;
}

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

.stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--color-border-hover);
}

.stat-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.icon-blue {
    background: rgba(59, 130, 246, 0.08);
}

.icon-green {
    background: rgba(16, 185, 129, 0.08);
}

.icon-purple {
    background: rgba(139, 92, 246, 0.08);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

/* ==========================================================================
   CONTROLS & FILTER BAR
   ========================================================================== */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    background: rgba(30, 41, 59, 0.2);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1rem;
}

@media (min-width: 768px) {
    .controls-section {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* Search bar */
.search-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

#search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 10px var(--color-primary-glow);
}

/* Select Filters */
.filters-wrapper {
    display: flex;
    gap: 1rem;
}

@media (max-width: 576px) {
    .filters-wrapper {
        flex-direction: column;
    }
}

.select-wrapper {
    position: relative;
}

.filters-wrapper select {
    appearance: none;
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 150px;
}

.filters-wrapper select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Custom dropdown arrow */
.select-wrapper::after {
    content: "↓";
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* ==========================================================================
   OUTLETS LISTING GRID
   ========================================================================== */
.outlets-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 576px) {
    .outlets-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .outlets-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Outlet Card Design */
.outlet-card {
    background: var(--color-bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.outlet-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    transition: background var(--transition-fast);
}

.outlet-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-border-hover);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.outlet-card.outlet-active:hover::before {
    background: linear-gradient(90deg, var(--color-success), var(--color-primary));
}

.outlet-card.outlet-inactive:hover::before {
    background: var(--color-danger);
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.card-badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge-code {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
}

.badge-type-outlet {
    background: var(--color-primary-glow);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.badge-type-backoffice {
    background: var(--color-purple-glow);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #c084fc;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.outlet-active .status-dot {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
    animation: flash 2s infinite;
}

.outlet-active .status-indicator {
    color: var(--color-success);
}

.outlet-inactive .status-dot {
    background-color: var(--color-danger);
    box-shadow: 0 0 6px var(--color-danger);
}

.outlet-inactive .status-indicator {
    color: var(--color-danger);
}

/* Card Body */
.card-body {
    margin-bottom: 1.5rem;
}

.outlet-title-container {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-bottom: 1rem;
}

.outlet-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
}

.outlet-title-zh {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.outlet-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.detail-icon {
    font-size: 1rem;
    color: var(--color-text-muted);
    width: 18px;
}

/* Card Footer */
.card-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1rem;
    margin-top: auto;
}

.address-box {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.address-text {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0.2rem;
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-copy:hover {
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.08);
}

/* Toast Notification (Copy success feedback) */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    color: #ffffff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    animation: slideInUp 0.3s var(--transition-normal);
}

/* ==========================================================================
   NO RESULTS CARD
   ========================================================================== */
.no-results-card {
    grid-column: 1 / -1;
    background: var(--color-bg-card);
    border: 1px dashed var(--color-border);
    border-radius: 20px;
    padding: 4rem 2rem;
    text-align: center;
}

.no-results-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 1rem;
}

.no-results-card h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.no-results-card p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes flash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ==========================================================================
   DEBUG INFO BOX STYLING
   ========================================================================== */
.debug-info-wrapper {
    margin-bottom: 2rem;
    width: 100%;
}


.debug-info-container {
    margin-top: 1rem;
    background: var(--color-bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    animation: slideUpFade var(--transition-normal);
}

.debug-header {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.debug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.debug-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    overflow: hidden;
}

.debug-card-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.25rem;
}

.debug-json {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    color: #a7f3d0;
    /* Soft green */
    max-height: 250px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}