/* --- 1. CORE VARIABLES --- */
:root {
    --varsys-gold: #FFCA13;
    --emergency-red: #E31E24;
    --text-dark: #333;
    --text-gray: #8E8E93;
    --bg-light: #F9F9F9;
    --card-bg: #FFFFFF;
}

body.dark-mode {
    --bg-light: #121212;
    --text-dark: #FFFFFF;
    --text-gray: #AEAEB2;
    --card-bg: #1C1C1E;
}

/* --- 2. GLOBAL RESET --- */
* {
    box-sizing: border-box;
    margin: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

body {
    background-color: #000;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    /* FIX: Set strict boundary using 100dvh to prevent body scroll */
    min-height: 100dvh;
    height: 100dvh; 
    margin: 0;
    overflow: hidden;
}

.app-shell {
    width: 100%;
    max-width: 430px;
    /* FIX: Use 100% of the strictly defined body height */
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    position: relative;
    background-color: var(--bg-light);
    /* FIX: Added safe area top padding so the header doesn't hide behind mobile status bars */
    padding-top: env(safe-area-inset-top);
}

/* --- 3. HEADER (INDEX CONSISTENCY) --- */
header {
    padding: clamp(10px, 3vh, 12px) clamp(16px, 5vw, 24px); 
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    z-index: 100;
}

body.dark-mode header { border-bottom: 1px solid #2C2C2E; }

.header-left {
    display: flex;
    align-items: center;
    gap: 5px;
}

.header-title { 
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.95rem, 4vw, 1.1rem); 
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: -0.5px;
}

#delete-mode-btn { background: none; border: none; font-size: clamp(1.1rem, 4.5vw, 1.2rem); color: var(--text-dark); cursor: pointer; }
#delete-mode-btn.active { color: var(--emergency-red); transform: scale(1.1); }

/* --- 4. CONTENT AREA & TABS --- */
.tab-selection {
    display: flex;
    justify-content: space-around;
    padding: clamp(8px, 2vh, 10px) 5px;
    background-color: var(--bg-light);
    position: sticky; top: 0; z-index: 10;
}

.tab-btn {
    flex: 1; 
    padding: clamp(10px, 3vw, 12px); 
    border: none; 
    background: transparent;
    font-weight: 700; 
    font-size: clamp(0.85rem, 3.5vw, 1rem); 
    color: var(--text-dark); 
    cursor: pointer;
}
.tab-btn.active { background-color: var(--varsys-gold); border-radius: 12px; color: #1a1a1a; }

.content-area { 
    flex: 1; 
    overflow-y: scroll; 
    overflow-x: hidden;
    padding: clamp(15px, 4vw, 20px); 
    background-color: var(--bg-light); 
    width: 100%;
}

/* --- 5. REPORT CARDS (EXPANDABLE LOGIC) --- */
.report-card {
    width: 100%;
    background: var(--card-bg);
    border-radius: clamp(14px, 4vw, 18px); 
    padding: clamp(15px, 4vw, 20px);       
    margin-bottom: clamp(12px, 3vw, 15px);
    border: 1px solid rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease, box-shadow 0.3s ease;
    max-height: clamp(120px, 25vh, 150px); 
}

.report-card.is-expanded {
    max-height: 2000px;
    border: 1.5px solid var(--varsys-gold);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

.card-expanded-content {
    display: block; 
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    padding-top: 0;
}

.is-expanded .card-expanded-content {
    max-height: 1800px;
    opacity: 1;
    padding-top: 15px;
    visibility: visible;
}

.expand-icon { transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.is-expanded .expand-icon { transform: rotate(180deg); }

.card-visible-part { width: 100%; display: flex; flex-direction: column; }
.card-body { display: flex; align-items: center; gap: clamp(10px, 3vw, 15px); width: 100%; }

.card-img { 
    width: clamp(40px, 12vw, 50px); 
    height: clamp(40px, 12vw, 50px); 
    object-fit: contain; 
}

.card-details h3 { font-size: clamp(0.9rem, 4vw, 1rem); font-weight: 800; color: var(--text-dark); }
.card-details p { font-size: clamp(0.75rem, 3.5vw, 0.85rem); color: var(--text-gray); }

.unread-indicator {
    position: absolute; 
    top: clamp(10px, 3vw, 15px); 
    right: clamp(10px, 3vw, 15px);
    width: clamp(8px, 2vw, 10px); 
    height: clamp(8px, 2vw, 10px);
    background-color: var(--varsys-gold);
    border-radius: 50%;
}

.card-date { 
    text-align: right; 
    font-size: clamp(0.65rem, 3vw, 0.75rem); 
    color: var(--text-gray); 
    margin-top: clamp(8px, 2vh, 10px); 
    width: 100%; display: block;
}

/* --- 6. EXPANDED CONTENT --- */
.card-expanded-content {
    opacity: 0; visibility: hidden; padding-top: 15px;
    display: none; transition: opacity 0.3s ease;
}
.is-expanded .card-expanded-content { opacity: 1; visibility: visible; display: block; }

.summary-divider { height: 1px; background: rgba(0,0,0,0.1); margin: 12px 0; }
body.dark-mode .summary-divider { background: rgba(255,255,255,0.1); }

.summary-section { margin-bottom: 15px; }
.summary-section label {
    font-size: clamp(0.65rem, 2.5vw, 0.7rem); 
    font-weight: 800; color: var(--varsys-gold);
    text-transform: uppercase; display: block; margin-bottom: 4px;
}
.summary-section p { font-size: clamp(0.8rem, 3.5vw, 0.9rem); color: var(--text-dark); }

.summary-photo-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: clamp(5px, 2vw, 8px); margin-top: 10px; width: 100%;
}
.summary-photo-item { text-align: center; }
.summary-photo-item img {
    width: 100%; aspect-ratio: 1; object-fit: cover;
    border-radius: 10px; border: 1px solid rgba(0,0,0,0.05);
}

.other-party-box {
    background: rgba(0,0,0,0.03); padding: clamp(10px, 3vw, 12px);
    border-radius: 12px; border-left: 4px solid var(--varsys-gold);
}
body.dark-mode .other-party-box { background: rgba(255,255,255,0.05); }

/* --- 7. DELETE MODE --- */
.report-card.delete-mode { padding-right: clamp(60px, 15vw, 70px); border: 1px solid var(--emergency-red) !important; }
.delete-overlay {
    position: absolute; top: 0; right: 0; height: 100%; 
    width: clamp(50px, 14vw, 60px);
    background: var(--emergency-red); display: none;
    justify-content: center; align-items: center; color: white;
    border-radius: 0 18px 18px 0;
}
.report-card.delete-mode .delete-overlay { display: flex; }

/* LIGHTBOX OVERLAY CSS */
#photo-lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.98); z-index: 9999;
    display: none; flex-direction: column; justify-content: center; align-items: center;
}
.lightbox-controls {
    position: absolute; bottom: clamp(30px, 8vh, 40px); 
    width: 90%; max-width: 400px;
    display: flex; justify-content: space-around; align-items: center;
    background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px);
    padding: clamp(10px, 3vw, 15px); border-radius: 50px; color: white; font-size: 1.4rem;
    z-index: 10000; border: 1px solid rgba(255,255,255,0.1);
}
.lightbox-controls i { cursor: pointer; width: 50px; height: 50px; display: flex; justify-content: center; align-items: center; }
.lightbox-controls i:active { transform: scale(0.9); color: #FFCA13; }
.lightbox-img-container { width: 100%; height: 60%; display: flex; justify-content: center; align-items: center; overflow: hidden; touch-action: none; }
#lightbox-img { max-width: 95%; max-height: 100%; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 8px; box-shadow: 0 0 30px rgba(0,0,0,0.5); }

/* --- DELETE MODAL STYLING --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px);
    display: none; justify-content: center; align-items: center;
    z-index: 10000; padding: 20px;
}

.modal-card {
    background: white; 
    width: 90%; 
    max-width: clamp(280px, 85vw, 320px);
    border-radius: clamp(20px, 5vw, 25px); 
    padding: clamp(20px, 6vw, 30px); 
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-icon {
    width: clamp(50px, 15vw, 60px); 
    height: clamp(50px, 15vw, 60px); 
    background: #fff5f5; color: #e31e24;
    font-size: clamp(1.5rem, 5vw, 1.8rem); 
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; margin: 0 auto 20px;
}

.modal-card h3 { font-weight: 800; margin-bottom: 10px; color: #1a1a1a; font-family: 'Montserrat'; font-size: clamp(1rem, 4vw, 1.2rem); }
.modal-card p { font-size: clamp(0.75rem, 3.5vw, 0.85rem); color: #666; line-height: 1.5; margin-bottom: 25px; }

.modal-actions { display: flex; gap: 12px; }
.modal-actions button {
    flex: 1; padding: clamp(12px, 3.5vw, 14px); border-radius: 12px; border: none;
    font-weight: 700; font-family: 'Montserrat'; font-size: clamp(0.75rem, 3.5vw, 0.8rem); cursor: pointer;
    transition: 0.2s;
}

.btn-cancel { background: #f2f2f7; color: #8e8e93; }
.btn-confirm-delete { background: #e31e24; color: white; }
.btn-confirm-delete:active { transform: scale(0.95); background: #c1181d; }

@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}
.bounce-in { animation: bounceIn 0.3s ease-out; }

.report-section {
    margin-top: 10px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.report-section i {
    font-size: 1.4rem;
   color: var(--text-gray);
    animation: bounceUp 2s infinite;
    margin-bottom: -10px;
}

.report-section i:last-of-type {
    margin-bottom: 5px;
}

.report-text {
font-family: 'Montserrat', sans-serif;
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--text-gray);
    margin-top: 4px;
}

/* Navigation Container */
nav {
    height: 80px; /* Panatilihin ang base height */
    background: #F9F9F9;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #EDEDED;
    
    /* ITO ANG PINAKAMALAKING PAGBABAGO */
    /* Magdadagdag tayo ng padding para umangat ang nav bar mula sa ilalim */
    padding-bottom: max(50px, env(safe-area-inset-bottom));
    
    /* Dagdagan ang height para magkasya ang padding sa loob */
    height: calc(100px + max(20px, env(safe-area-inset-bottom)));
    
    z-index: 1000;
}

/* Consistent Nav Item */
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8E8E93;
    flex: 1;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    height: 100%;
}

/* Icons: Consistent Size & Alignment */
.nav-item i {
    font-size: 1.3rem;
    height: 30px; 
    display: flex;
    align-items: center;
    margin-bottom: 2px;
    transition: color 0.3s ease;
}

/* Labels: Consistent Font Size */
.nav-item span {
    font-size: 10px;   /* Fixed font size: saktong-sakto sa mobile */
    font-weight: 400;
    font-family: 'Montserrat', sans-serif;
    transition: color 0.3s ease;
}


/* --- ACTIVE STATE (Consistent Colors) --- */
.nav-item.active {
    color: #FFCA13; /* Varsys Gold */
}

.nav-item.active i, 
.nav-item.active span {
    color: #FFCA13;
    font-weight: 700;
}

/* --- BADGE: Consistent Position --- */
.badge {
    position: absolute;
    top: 10px;
    right: 20%; 
    background: #FF3B30;
    color: white;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #F9F9F9;
    z-index: 2;
}

.emergency-wrapper {
    position: relative;
    top: -25px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.emergency-btn {
    width: 68px;
    height: 68px;
    text-decoration: none;
    background-color: var(--emergency-red);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.5rem;
    transition: transform 0.2s active;
}

.emergency-btn:active {
    transform: scale(0.9);
}

.emergency-text {
    color: var(--emergency-red);
    font-weight: 800;
    font-size: 0.6rem;
    margin-top: 8px;
    letter-spacing: 0.5px;
    font-family: 'Montserrat', sans-serif;;
}

/* Requirements Section Styling */
.requirements-container {
    margin-top: clamp(15px, 4vw, 25px);
    padding: clamp(15px, 4vw, 20px);
    background: #FFF4E5; 
    border-radius: clamp(10px, 3vw, 15px);
    border: 1px solid #FFE0B2;
}

.req-header { display: flex; align-items: center; gap: 10px; margin-bottom: clamp(10px, 3vw, 15px); }
.req-header i { color: #F57C00; }
.req-header h3 { margin: 0; font-size: clamp(0.8rem, 3.5vw, 0.9rem); font-weight: 700; color: #E65100; text-transform: uppercase; }

.req-item-card {
    background: #ffffff; padding: clamp(10px, 3vw, 15px); border-radius: 10px;
    margin-bottom: 10px; display: flex; justify-content: space-between;
    align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.req-name { font-size: clamp(0.75rem, 3.5vw, 0.85rem); font-weight: 600; color: #333; }

.upload-btn-mini {
    background: var(--varsys-gold); color: #000; border: none;
    padding: clamp(4px, 1.5vw, 6px) clamp(8px, 2.5vw, 12px); border-radius: 6px;
    font-size: clamp(0.6rem, 2.5vw, 0.7rem); font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 5px;
}

.req-item-card.completed { border-left: 4px solid #2ecc71; }

.footer-hint { cursor: pointer; transition: all 0.3s ease; padding: 10px; }
.footer-hint:active { transform: scale(0.95); opacity: 0.7; }

/* --- PAGE TRANSITION ANIMATION --- */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-area { animation: slideUpFade 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards; will-change: transform, opacity; }
.page-exit { opacity: 0; transform: translateY(-20px); transition: all 0.3s ease-in; }

/* --- DARK MODE --- */
body.dark-mode .modal-card { background: #1c1c1e; }
body.dark-mode .modal-card h3 { color: #fff; }
body.dark-mode .modal-card p { color: #aaa; }
body.dark-mode .btn-cancel { background: #2c2c2e; color: #fff; }
body.dark-mode nav { background-color:#121212; border-color: #2C2C2E; }
body.dark-mode .nav-item.active { background: #1C1C1E; border-color: #FFCA13; }
body.dark-mode .nav-item.active span, body.dark-mode .nav-item.active i { color: #FFCA13; }
body.dark-mode .badge { border-color: #121212; }
body.dark-mode .card-details h3 { color: #AEAEB2; }
body.dark-mode .card-details { color: #C7C7CC; }