/* ============================================
   RTC WIFI - Mobile-First Portal CSS
   Premium Dark Theme with Animations
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.3);
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --purple: #8b5cf6;
    
    --bg-deep: #0a0e1a;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #253349;
    --border: #334155;
    --border-glow: rgba(99, 102, 241, 0.15);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== Animated Background ===== */
.bg-mesh {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0;
    overflow: hidden;
}

.bg-mesh::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--primary-glow), transparent 70%);
    top: -200px; right: -200px;
    animation: floatBlob 15s ease-in-out infinite;
}

.bg-mesh::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    bottom: -200px; left: -200px;
    animation: floatBlob 18s ease-in-out infinite reverse;
}

@keyframes floatBlob {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(50px, -30px) scale(1.1); }
    50% { transform: translate(-30px, 50px) scale(0.9); }
    75% { transform: translate(40px, 20px) scale(1.05); }
}

/* ===== Page Container ===== */
.page-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 0;
    max-width: 480px;
    margin: 0 auto;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1.5rem;
}

.login-logo {
    width: 90px; height: 90px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 900;
    color: white;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 40px var(--primary-glow);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 10px 40px var(--primary-glow); }
    50% { transform: scale(1.05); box-shadow: 0 15px 60px var(--primary-glow); }
}

.login-title {
    font-size: 2rem;
    font-weight: 800;
    color: white;
    margin-bottom: 0.3rem;
    animation: fadeSlideUp 0.8s ease-out;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2.5rem;
    animation: fadeSlideUp 0.8s ease-out 0.1s both;
}

.login-card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: fadeSlideUp 0.8s ease-out 0.2s both;
}

.input-wrapper {
    position: relative;
    margin-bottom: 1.2rem;
}

.input-wrapper i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.3s;
}

.input-wrapper input {
    width: 100%;
    padding: 1rem 1rem 1rem 1rem;
    padding-right: 3rem;
    background: var(--bg-main);
    border: 2px solid var(--border);
    border-radius: 16px;
    color: white;
    font-size: 1.1rem;
    font-family: 'Tajawal', sans-serif;
    text-align: center;
    letter-spacing: 2px;
    outline: none;
    transition: all 0.3s ease;
}

.input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.input-wrapper input:focus + i,
.input-wrapper input:focus ~ i {
    color: var(--primary);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
    letter-spacing: 0;
    font-size: 0.95rem;
}

.btn-login {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-login:hover::before {
    left: 100%;
}

.btn-login:active {
    transform: scale(0.97);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

/* ===== Dashboard Page ===== */
.dash-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.dash-header-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.dash-header-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: white;
}

.dash-header-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.dash-header-text span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-logout {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Dashboard Content */
.dash-content {
    padding: 1.5rem;
}

/* Welcome Card */
.welcome-card {
    background: linear-gradient(135deg, var(--primary), #4338ca);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    animation: fadeSlideUp 0.6s ease-out;
}

.welcome-card::before {
    content: '';
    position: absolute;
    width: 200px; height: 200px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    top: -80px; left: -80px;
}

.welcome-card::after {
    content: '';
    position: absolute;
    width: 150px; height: 150px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    bottom: -60px; right: -60px;
}

.welcome-card .welcome-text {
    position: relative;
    z-index: 1;
}

.welcome-card .greeting {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 0.2rem;
}

.welcome-card .username {
    font-size: 1.4rem;
    font-weight: 800;
    color: white;
}

.welcome-card .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255,255,255,0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: white;
    margin-top: 0.5rem;
    backdrop-filter: blur(10px);
}

.welcome-card .status-dot {
    width: 8px; height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: fadeSlideUp 0.6s ease-out both;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.stat-card:active {
    transform: scale(0.97);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
}

.stat-card.blue::before { background: linear-gradient(90deg, var(--info), #60a5fa); }
.stat-card.green::before { background: linear-gradient(90deg, var(--accent), #34d399); }
.stat-card.orange::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--purple), #a78bfa); }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.6rem;
    font-size: 1.2rem;
}

.stat-card.blue .stat-icon { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.stat-card.green .stat-icon { background: rgba(16, 185, 129, 0.15); color: var(--accent); }
.stat-card.orange .stat-icon { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-card.purple .stat-icon { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
}

.stat-card.blue .stat-value { color: var(--info); }
.stat-card.green .stat-value { color: var(--accent); }
.stat-card.orange .stat-value { color: var(--warning); }
.stat-card.purple .stat-value { color: var(--purple); }

.stat-unit {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
}

/* Expiry Card */
.expiry-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: fadeSlideUp 0.6s ease-out 0.5s both;
}

.expiry-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.expiry-icon {
    width: 44px; height: 44px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.expiry-text .expiry-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.expiry-text .expiry-date {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.days-badge {
    background: linear-gradient(135deg, var(--info), #2563eb);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    text-align: center;
    min-width: 70px;
}

.days-badge.warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
}

.days-badge.danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
}

/* Progress Bar */
.progress-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1rem;
    animation: fadeSlideUp 0.6s ease-out 0.6s both;
}

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

.progress-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--info);
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--bg-main);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--primary), var(--purple));
    transition: width 1.5s ease-out;
    animation: progressGlow 2s ease-in-out infinite;
}

@keyframes progressGlow {
    0%, 100% { box-shadow: 0 0 5px var(--primary-glow); }
    50% { box-shadow: 0 0 15px var(--primary-glow); }
}

/* Footer */
.portal-footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    animation: fadeSlideUp 0.6s ease-out 0.7s both;
}

/* ===== Animations ===== */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Loading Spinner ===== */
.spinner {
    display: none;
    width: 24px; height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* ===== Ripple Effect ===== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    top: 0; left: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 10%, transparent 10.01%);
    transform: scale(10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s;
}

.ripple:active::after {
    transform: scale(0);
    opacity: 1;
    transition: 0s;
}

/* Safe area for notch phones */
@supports (padding-top: env(safe-area-inset-top)) {
    .dash-header {
        padding-top: calc(1.2rem + env(safe-area-inset-top));
    }
}
