/* ==========================================================================
   AMINTECH DESIGN SYSTEM TOKENS & CORE UTILITIES
   Strict 8px Grid | 12px Radius Cards | Dark + Light Mode | Mobile First
   Brand Gradient: Magenta #CA09E5 -> Navy #121068
   ========================================================================== */

[x-cloak] {
    display: none !important;
}

:root {
    /* Brand Gradient & Accents (strictly hero & primary CTAs) */
    --ami-brand-gradient: linear-gradient(135deg, #CA09E5 0%, #121068 100%);
    --ami-brand-gradient-hover: linear-gradient(135deg, #B207CC 0%, #0E0C53 100%);
    --ami-brand-magenta: #CA09E5;
    --ami-brand-navy: #121068;
    --ami-brand-navy-light: #1E1B8C;
    --ami-brand-glow: rgba(202, 9, 229, 0.28);

    /* Typography */
    --ami-font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ami-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* 8px Spacing Grid */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Corner Radii */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 12px;  /* standard card & tile radius */
    --radius-lg: 16px;  /* hero containers, modals */
    --radius-xl: 20px;
    --radius-pill: 9999px;

    /* Light Mode Surface Palette (Default) */
    --ami-bg: #F8FAFC;
    --ami-surface: #FFFFFF;
    --ami-surface-subtle: #F1F5F9;
    --ami-surface-hover: #E2E8F0;
    --ami-border: #E2E8F0;
    --ami-border-strong: #CBD5E1;
    --ami-text-primary: #0F172A;
    --ami-text-secondary: #475569;
    --ami-text-muted: #94A3B8;
    --ami-text-inverse: #FFFFFF;

    /* Semantic Status Tokens - Light */
    --ami-success: #10B981;
    --ami-success-bg: #ECFDF5;
    --ami-success-border: #A7F3D0;
    --ami-success-text: #065F46;

    --ami-warning: #F59E0B;
    --ami-warning-bg: #FFFBEB;
    --ami-warning-border: #FDE68A;
    --ami-warning-text: #92400E;

    --ami-danger: #EF4444;
    --ami-danger-bg: #FEF2F2;
    --ami-danger-border: #FECACA;
    --ami-danger-text: #991B1B;

    --ami-info: #3B82F6;
    --ami-info-bg: #EFF6FF;
    --ami-info-border: #BFDBFE;
    --ami-info-text: #1E40AF;

    --ami-purple: #8B5CF6;
    --ami-purple-bg: #F5F3FF;
    --ami-purple-border: #DDD6FE;
    --ami-purple-text: #5B21B6;

    /* Elevation & Shadows */
    --ami-shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --ami-shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
    --ami-shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --ami-shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
    --ami-shadow-hero: 0 12px 28px -6px rgba(18, 16, 104, 0.28);
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --ami-bg: #090D16;
    --ami-surface: #111827;
    --ami-surface-subtle: #1F2937;
    --ami-surface-hover: #374151;
    --ami-border: #2E3A4D;
    --ami-border-strong: #475569;
    --ami-text-primary: #F8FAFC;
    --ami-text-secondary: #CBD5E1;
    --ami-text-muted: #64748B;
    --ami-text-inverse: #0F172A;

    /* Semantic Status Tokens - Dark */
    --ami-success-bg: rgba(16, 185, 129, 0.15);
    --ami-success-border: rgba(16, 185, 129, 0.35);
    --ami-success-text: #34D399;

    --ami-warning-bg: rgba(245, 158, 11, 0.15);
    --ami-warning-border: rgba(245, 158, 11, 0.35);
    --ami-warning-text: #FBBF24;

    --ami-danger-bg: rgba(239, 68, 68, 0.15);
    --ami-danger-border: rgba(239, 68, 68, 0.35);
    --ami-danger-text: #F87171;

    --ami-info-bg: rgba(59, 130, 246, 0.15);
    --ami-info-border: rgba(59, 130, 246, 0.35);
    --ami-info-text: #60A5FA;

    --ami-purple-bg: rgba(139, 92, 246, 0.15);
    --ami-purple-border: rgba(139, 92, 246, 0.35);
    --ami-purple-text: #C4B5FD;

    --ami-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --ami-shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5);
    --ami-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
    --ami-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.7);
    --ami-shadow-hero: 0 12px 28px -6px rgba(0, 0, 0, 0.85);
}

/* ==========================================================================
   GLOBAL BASE STYLES & RESETS
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--ami-font-sans);
    background-color: var(--ami-bg);
    color: var(--ami-text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    padding-bottom: 72px; /* allowance for mobile bottom bar */
    transition: background-color 0.2s ease, color 0.2s ease;
}

@media (min-width: 992px) {
    body {
        padding-bottom: 0;
    }
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */
.ami-card {
    background-color: var(--ami-surface);
    border: 1px solid var(--ami-border);
    border-radius: var(--radius-md);
    box-shadow: var(--ami-shadow-sm);
    padding: var(--space-4);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.ami-card-interactive {
    cursor: pointer;
}

.ami-card-interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--ami-shadow-md);
    border-color: var(--ami-brand-magenta);
}

/* Brand Hero Balance Card */
.ami-hero-card {
    background: var(--ami-brand-gradient);
    color: #FFFFFF;
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--ami-shadow-hero);
    position: relative;
    overflow: hidden;
}

.ami-hero-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
    border-radius: 50%;
}

.ami-hero-card .balance-amount {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 576px) {
    .ami-hero-card .balance-amount {
        font-size: 1.85rem;
    }
}

/* ==========================================================================
   PRIMARY BRAND BUTTONS & ACTIONS
   ========================================================================== */
.btn-ami-primary {
    background: var(--ami-brand-gradient);
    color: #FFFFFF !important;
    border: none;
    border-radius: var(--radius-pill);
    font-weight: 600;
    padding: 10px 24px;
    box-shadow: 0 4px 14px 0 var(--ami-brand-glow);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-ami-primary:hover {
    background: var(--ami-brand-gradient-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px 0 rgba(202, 9, 229, 0.38);
}

.btn-ami-primary:active {
    transform: translateY(0);
}

.btn-ami-subtle {
    background-color: var(--ami-surface-subtle);
    color: var(--ami-text-primary);
    border: 1px solid var(--ami-border);
    border-radius: var(--radius-pill);
    font-weight: 600;
    padding: 8px 18px;
    transition: all 0.15s ease;
}

.btn-ami-subtle:hover {
    background-color: var(--ami-surface-hover);
    color: var(--ami-text-primary);
}

/* White Hero CTA button */
.btn-ami-hero {
    background: #FFFFFF;
    color: var(--ami-brand-navy) !important;
    border-radius: var(--radius-pill);
    font-weight: 700;
    padding: 10px 22px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.15s ease;
}

.btn-ami-hero:hover {
    background: #F8FAFC;
    transform: translateY(-1px);
}

/* ==========================================================================
   FORM CONTROLS (Label Above, Helper Text, Inline Errors)
   ========================================================================== */
.ami-form-group {
    margin-bottom: var(--space-4);
}

.ami-form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ami-text-primary);
    margin-bottom: var(--space-1);
}

.ami-form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--ami-text-primary);
    background-color: var(--ami-surface);
    border: 1.5px solid var(--ami-border);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.ami-form-control:focus {
    outline: none;
    border-color: var(--ami-brand-magenta);
    box-shadow: 0 0 0 3px var(--ami-brand-glow);
    background-color: var(--ami-surface);
}

.ami-form-helper {
    font-size: 0.8rem;
    color: var(--ami-text-muted);
    margin-top: var(--space-1);
}

.ami-form-error {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ami-danger);
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   NETWORK SELECTOR TILES (Replaces Clunky HTML Dropdowns)
   ========================================================================== */
.ami-network-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

@media (max-width: 576px) {
    .ami-network-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.ami-network-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-2);
    background-color: var(--ami-surface);
    border: 2px solid var(--ami-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.ami-network-tile:hover {
    border-color: var(--ami-brand-magenta);
    background-color: var(--ami-surface-subtle);
}

.ami-network-tile.active {
    border-color: var(--ami-brand-magenta);
    background-color: rgba(202, 9, 229, 0.05);
    box-shadow: 0 0 0 3px var(--ami-brand-glow);
}

[data-theme="dark"] .ami-network-tile.active {
    background-color: rgba(202, 9, 229, 0.15);
}

.ami-network-tile img {
    height: 38px;
    width: auto;
    object-fit: contain;
    margin-bottom: var(--space-1);
}

.ami-network-tile .tile-title {
    font-size: 0.825rem;
    font-weight: 700;
    color: var(--ami-text-primary);
}

.ami-network-tile .tile-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    background: var(--ami-brand-magenta);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.ami-network-tile.active .tile-check {
    display: flex;
}

/* ==========================================================================
   PLAN CHIPS & PLAN SELECTION CARDS
   ========================================================================== */
.ami-plan-type-chips {
    display: flex;
    flex-wrap: nowrap;             /* one straight line, never a sideways scroller: chips share the width equally */
    gap: 8px;
    margin-bottom: var(--space-4);
}

.ami-chip {
    padding: 6px 14px;
    font-size: 0.825rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    background-color: var(--ami-surface-subtle);
    color: var(--ami-text-secondary);
    border: 1px solid var(--ami-border);
    cursor: pointer;
    white-space: normal;
    transition: all 0.15s ease;
    flex: 1 1 0;                   /* equal-width targets; long labels wrap inside their chip */
    min-width: 0;
    overflow-wrap: break-word;
    min-height: 52px;
    padding: 10px 8px;
    font-size: 0.8rem;
    line-height: 1.25;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 768px) {
    .ami-plan-type-chips { gap: 12px; }
    .ami-chip { padding: 12px 16px; font-size: 0.94rem; min-height: 54px; }
}

.ami-chip:hover {
    border-color: var(--ami-brand-magenta);
    color: var(--ami-text-primary);
}

.ami-chip.active {
    background: var(--ami-brand-gradient);
    color: #FFFFFF;
    border-color: transparent;
    box-shadow: 0 2px 8px var(--ami-brand-glow);
}

/* Plan Card */
.ami-plan-card {
    background-color: var(--ami-surface);
    border: 1.5px solid var(--ami-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.ami-plan-card:hover {
    border-color: var(--ami-brand-magenta);
    transform: translateX(2px);
}

.ami-plan-card.active {
    border-color: var(--ami-brand-magenta);
    background-color: rgba(202, 9, 229, 0.04);
    box-shadow: 0 0 0 2px var(--ami-brand-glow);
}

[data-theme="dark"] .ami-plan-card.active {
    background-color: rgba(202, 9, 229, 0.12);
}

.ami-plan-card .plan-size {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ami-text-primary);
}

.ami-plan-card .plan-validity {
    font-size: 0.775rem;
    color: var(--ami-text-muted);
}

.ami-plan-card .plan-price {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--ami-brand-magenta);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   SEMANTIC STATUS BADGES
   ========================================================================== */
.ami-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    text-transform: capitalize;
}

.ami-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.ami-badge-success {
    background-color: var(--ami-success-bg);
    border-color: var(--ami-success-border);
    color: var(--ami-success-text);
}
.ami-badge-success .ami-badge-dot { background-color: var(--ami-success); }

.ami-badge-warning {
    background-color: var(--ami-warning-bg);
    border-color: var(--ami-warning-border);
    color: var(--ami-warning-text);
}
.ami-badge-warning .ami-badge-dot { background-color: var(--ami-warning); }

.ami-badge-danger {
    background-color: var(--ami-danger-bg);
    border-color: var(--ami-danger-border);
    color: var(--ami-danger-text);
}
.ami-badge-danger .ami-badge-dot { background-color: var(--ami-danger); }

.ami-badge-info {
    background-color: var(--ami-info-bg);
    border-color: var(--ami-info-border);
    color: var(--ami-info-text);
}
.ami-badge-info .ami-badge-dot { background-color: var(--ami-info); }

.ami-badge-purple {
    background-color: var(--ami-purple-bg);
    border-color: var(--ami-purple-border);
    color: var(--ami-purple-text);
}
.ami-badge-purple .ami-badge-dot { background-color: var(--ami-purple); }

/* ==========================================================================
   SKELETON LOADERS (Zero full-page overlay spinners)
   ========================================================================== */
.ami-skeleton {
    background: linear-gradient(90deg,
        var(--ami-surface-subtle) 25%,
        var(--ami-surface-hover) 50%,
        var(--ami-surface-subtle) 75%
    );
    background-size: 200% 100%;
    animation: ami-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    display: inline-block;
}

@keyframes ami-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   MOBILE BOTTOM NAVIGATION (Fixed, High Contrast, App-Like)
   ========================================================================== */
.ami-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: var(--ami-surface);
    border-top: 1px solid var(--ami-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1030;
    padding: 4px 8px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.ami-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--ami-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: color 0.15s ease;
    flex: 1;
}

.ami-bottom-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.ami-bottom-nav-item:hover,
.ami-bottom-nav-item.active {
    color: var(--ami-brand-magenta);
}

/* ==========================================================================
   PIN PAD MODAL / REVIEW SHEET
   ========================================================================== */
.ami-pin-input-group {
    display: flex;
    justify-content: center;
    gap: min(var(--space-3), 2.2vw);
    margin: var(--space-4) 0;
}

.ami-pin-digit {
    width: 52px;
    max-width: 15vw;
    height: 56px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    border: 2px solid var(--ami-border);
    border-radius: var(--radius-md);
    background-color: var(--ami-surface);
    color: var(--ami-text-primary);
    transition: all 0.15s ease;
}

.ami-pin-digit:focus {
    outline: none;
    border-color: var(--ami-brand-magenta);
    box-shadow: 0 0 0 3px var(--ami-brand-glow);
}

/* ==========================================================================
   TOAST NOTIFICATION STACK (Replaces SweetAlert / Toastr)
   ========================================================================== */
#ami-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 380px;
    pointer-events: none;
}

.ami-toast {
    pointer-events: auto;
    background-color: var(--ami-surface);
    border: 1px solid var(--ami-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--ami-shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    animation: ami-toast-in 0.25s ease-out;
}

@keyframes ami-toast-in {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Shown in place of a logo that has not been uploaded (see templates/includes/brand_logo.html) */
.ami-logo-abbr {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    min-width: 38px;
    padding: 0 0.5rem;
    margin-bottom: var(--space-1);
    border-radius: 10px;
    background-color: var(--ami-surface-subtle);
    border: 1px solid var(--ami-border);
    color: var(--ami-text-primary);
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}
