/* --- 1. GLOBAL ROOT VARIABLES --- */
:root {
    --primary: #FF3B30;          /* Professional Medical Red */
    --primary-dark: #D70015;
    --bg-body: #F2F2F7;          /* iOS style light grey background */
    --surface: #FFFFFF;
    --text-main: #1C1C1E;
    --text-sec: #8E8E93;
    --success: #34C759;
    --warning: #FF9500;
    --shadow-soft: 0 8px 24px rgba(149, 157, 165, 0.1);
    --shadow-strong: 0 12px 30px rgba(0, 0, 0, 0.08);
}

/* --- 2. BASE RESET --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    padding-bottom: 100px; /* Space for bottom nav */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    line-height: 1.5;
}

/* --- 3. PRELOADER --- */
#app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 20000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.logo-pulse {
    animation: pulse-logo 2s infinite ease-in-out;
    color: var(--primary);
    font-size: 4rem;
}

@keyframes pulse-logo {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- 4. AUTH SCREENS (Login/Signup) --- */
#auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 40px 24px;
    overflow-y: auto;
}

.auth-card-width {
    width: 100%;
    max-width: 380px;
}

/* 50 Years Statehood Banner */
.statehood-container {
    width: 100%;
    max-width: 280px;
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
}

.statehood-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.1));
}

/* --- 5. UI COMPONENTS --- */

/* App Header (Glassmorphism) */
.glass-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Standard App Cards */
.app-card {
    background: var(--surface);
    border-radius: 20px;
    border: none;
    box-shadow: var(--shadow-soft);
    margin-bottom: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-card:active {
    transform: scale(0.98);
}

/* Buttons */
.btn-primary-app {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: 14px;
    padding: 14px;
    font-weight: 600;
    color: white;
    box-shadow: 0 6px 15px rgba(255, 59, 48, 0.25);
    transition: 0.3s;
}

.btn-primary-app:active {
    transform: scale(0.96);
    opacity: 0.9;
}

.btn-primary-app:disabled {
    background: #D1D1D6;
    box-shadow: none;
}

/* Blood Avatar (Icon/Badge) */
.blood-avatar {
    width: 52px;
    height: 52px;
    background: #FFF0F0;
    color: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.blood-avatar.sm {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
    border-radius: 12px;
}

/* --- 6. DONOR & REQUEST CARDS --- */
.req-card {
    padding: 20px;
    background: white;
    border-radius: 22px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-soft);
    border: 1px solid transparent;
    position: relative;
    transition: 0.3s;
}

.req-card.emergency {
    border-left: 6px solid var(--primary);
    background: #FFF9F9;
}

.urgency-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
}

/* --- 7. BOTTOM NAVIGATION --- */
.bottom-nav {
    position: fixed;
    bottom: 25px;
    left: 5%;
    width: 90%;
    background: rgba(28, 28, 30, 0.92);
    backdrop-filter: blur(12px);
    border-radius: 28px;
    display: flex;
    justify-content: space-around;
    padding: 16px 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    z-index: 1050;
}

.nav-item {
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    font-size: 1.4rem;
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    cursor: pointer;
}

.nav-item.active {
    color: #ffffff;
    transform: translateY(-5px);
}

.nav-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    border: 2px solid #1c1c1e;
    display: none;
}

/* --- 8. MODALS & FILTERS --- */
.modal-content {
    border-radius: 30px;
    border: none;
    padding: 10px;
}

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

.filter-opt {
    border: 1.5px solid #E5E5EA;
    border-radius: 14px;
    padding: 12px 5px;
    text-align: center;
    font-weight: 600;
    color: #3A3A3C;
    cursor: pointer;
    font-size: 0.8rem;
    background: #ffffff;
    transition: 0.2s;
}

.filter-opt.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(255, 59, 48, 0.2);
}

/* --- 9. TOAST NOTIFICATIONS --- */
#toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 21000;
    width: 90%;
    max-width: 400px;
}

.toast-msg {
    background: rgba(0, 0, 0, 0.88);
    color: #ffffff;
    padding: 16px 20px;
    border-radius: 18px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    animation: slideDown 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-size: 0.9rem;
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- 10. DEVELOPER FOOTER --- */
.dev-footer {
    margin-top: auto;
    padding: 30px 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-sec);
    letter-spacing: 0.3px;
}

/* --- 11. FORM CONTROLS --- */
.form-control, .form-select {
    border: 1.5px solid #F2F2F7;
    background-color: #F2F2F7;
    transition: 0.2s;
}

.form-control:focus, .form-select:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: none;
}

/* Segmented Control (Inbox/Sent Tabs) */
.btn-white {
    background: transparent;
    color: var(--text-sec);
    border: none;
    font-weight: 500;
}

.d-none { display: none !important; }

/* Image handling fix for the logout bug */
#app-small-logo {
    display: block;
    min-width: 30px;
    min-height: 30px;
    object-fit: contain;
}

img {
    transition: opacity 0.3s ease-in;
}