.hidden { display: none !important; }

/* Global Styles */
html { font-size: 14px; -webkit-tap-highlight-color: transparent; }

body { 
    font-family: 'Battambang', 'Noto Sans Khmer', sans-serif; 
    background-color: #f1f5f9; 
    color: #0f172a;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

@media (min-width: 640px) { html { font-size: 16px; } }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Dashboard View Styles */
#dashboard .ink-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

@media (min-width: 640px) {
    #dashboard .ink-card {
        border-top: 3px solid #0c4a6e;
    }
}

#dashboard .modern-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #cbd5e1; /* Thinner border for modern look */
    border-radius: 12px;
    font-family: 'Battambang';
    font-weight: 600;
    color: #0c4a6e;
    background-color: #f8fafc;
    transition: all 0.2s;
}

#dashboard .modern-input:focus {
    border-color: #0ea5e9;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); /* Softer glow */
    outline: none;
}

#dashboard .custom-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%230369a1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.2em;
}

#dashboard .btn-ink {
    background-color: #0c4a6e; 
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-weight: 700;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(12, 74, 110, 0.3);
}

#dashboard .btn-ink:hover { background-color: #075985; transform: translateY(-1px); }

#dashboard .btn-ink:active { transform: translateY(0); }

#dashboard .tab-container {
    background-color: #fff; /* White background for tab container */
    padding: 0.4rem;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    gap: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

#dashboard .tab-btn {
    padding: 0.6rem 1.2rem;
    font-weight: 700;
    color: #64748b;
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

#dashboard .tab-btn:hover:not(.active) {
    background-color: #f1f5f9;
    color: #475569;
}

#dashboard .tab-btn.active {
    color: white;
    background: linear-gradient(135deg, #0c4a6e, #075985); /* Gradient for active tab */
    box-shadow: 0 2px 4px rgba(12, 74, 110, 0.2);
}

#dashboard .table-row { transition: background 0.15s; border-bottom: 1px solid #f1f5f9; }

#dashboard .table-row:hover { background-color: #f0f9ff; }

#dashboard .overlay-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px);
    z-index: 50; display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
}

#dashboard .overlay-backdrop.show { opacity: 1; pointer-events: auto; }

#dashboard .modal-content {
    background: white; width: 90%; max-width: 400px; padding: 2rem;
    border-radius: 24px; text-align: center;
    transform: scale(0.95); transition: transform 0.2s;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

#dashboard .overlay-backdrop.show .modal-content { transform: scale(1); }

#dashboard #iframe-modal {
    padding: 0 !important;
    z-index: 2000;
    background: rgba(0,0,0,0.85);
}

#dashboard #iframe-modal .iframe-box {
    width: 100%; height: 100%; background: white; overflow: hidden;
    position: relative; display: flex; flex-direction: column;
}

@media (min-width: 1024px) {
    #dashboard #iframe-modal { padding: 1.5rem !important; }
    #dashboard #iframe-modal .iframe-box { 
        width: 100%; max-width: 1200px; height: 100%; max-height: 95vh;
        border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    }
}

#dashboard .close-iframe-btn {
    position: absolute; top: 10px; right: 10px; z-index: 50;
    width: 36px; height: 36px; background-color: #ef4444; color: white;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background-color 0.2s; cursor: pointer; border: 2px solid white;
}

#dashboard .close-iframe-btn:hover { background-color: #dc2626; transform: scale(1.1); }
#dashboard .close-iframe-btn:active { transform: scale(0.95); }
#dashboard .khmer-num { font-family: 'Battambang', sans-serif; font-weight: bold; }

/* =========================================
   ENTRY VIEW STYLES (Improved Visuals)
   ========================================= */

#entry .form-container {
    width: 95%; 
    max-width: 1000px;
    margin: 15px auto;
    background: #ffffff;
    border-radius: 20px; /* More rounded */
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.08), 0 4px 10px -2px rgba(0, 0, 0, 0.04); /* Softer, deeper shadow */
    overflow: hidden;
    border: 1px solid #e2e8f0;
    position: relative;
}

@media (min-width: 768px) {
    #entry .form-container {
        width: 100%;
        margin: 30px auto;
        border-radius: 24px;
        box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.1);
    }
}

#entry .input-label { 
    display: block; 
    font-size: 0.9rem; 
    font-weight: 700; 
    color: #475569; 
    margin-bottom: 0.5rem; 
    transition: color 0.2s;
}

@media (min-width: 768px) { #entry .input-label { font-size: 0.95rem; } }

#entry .form-input {
    width: 100%; 
    padding: 0.75rem 1rem; /* More padding */
    border: 1px solid #cbd5e1; /* Thinner default border */
    border-radius: 12px; 
    font-family: 'Battambang'; 
    font-size: 15px; 
    color: #0f172a; 
    font-weight: 600;
    background-color: #f8fafc; /* Slight off-white background */
    transition: all 0.2s ease-in-out;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

@media (min-width: 768px) {
    #entry .form-input { padding: 0.85rem 1rem; font-size: 1rem; }
}

#entry .form-input:hover {
    border-color: #94a3b8; 
    background-color: #fff;
}

#entry .form-input:focus { 
    outline: none; 
    border-color: #3b82f6; /* Bright Blue */
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); /* Soft focus ring */
    transform: translateY(-1px); 
}

#entry div:focus-within > .input-label { color: #2563eb; }

#entry .form-input.latin { font-family: 'Poppins', sans-serif; text-transform: uppercase; letter-spacing: 0.5px; }

#entry .form-input[readonly] { 
    background-color: #f1f5f9; color: #64748b; cursor: not-allowed; 
    border-color: #e2e8f0; box-shadow: none;
}

#entry .input-pob-1 { border-left: 5px solid #f59e0b; }
#entry .input-pob-2 { border-left: 5px solid #10b981; }

/* Date Widget Improvements */
#entry .date-widget { 
    display: flex; width: 100%; background: #fff; 
    border: 1px solid #cbd5e1; /* Thinner border */
    border-top-left-radius: 12px; border-top-right-radius: 12px; 
    overflow: hidden; 
    transition: all 0.25s ease;
    background-color: #f8fafc;
}

@media (min-width: 768px) { #entry .date-widget { border-top-left-radius: 14px; border-top-right-radius: 14px; } }

#entry .date-widget:focus-within { 
    border-color: #3b82f6; 
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); 
}

#entry .date-box { 
    border: none; padding: 0.75rem 0.2rem; text-align: center; 
    font-family: 'Battambang'; font-weight: bold; 
    background: transparent; color: #1e40af; outline: none; 
    border-right: 1px solid #e2e8f0; cursor: pointer; 
    transition: background 0.2s; 
    font-size: 0.9rem;
}

@media (min-width: 768px) { #entry .date-box { padding: 0.85rem 0.2rem; font-size: 1rem; } }

#entry .date-box:last-child { border-right: none; }
#entry .date-dow { width: 30%; background-color: #f1f5f9; color: #475569; font-size: 0.8rem; }
#entry .date-day { width: 15%; }
#entry .date-month { flex-grow: 1; min-width: 0; }
#entry .date-year { width: 25%; }

#entry .date-result-input { 
    border: 1px solid #cbd5e1; 
    border-top: none; 
    border-bottom-left-radius: 12px; border-bottom-right-radius: 12px;
    background-color: #eff6ff; /* Very light blue */
    color: #1d4ed8; 
    font-size: 15px; width: 100%; padding: 0.75rem 1rem;
    display: block; font-weight: 700; text-align: center; 
    transition: all 0.2s;
}

@media (min-width: 768px) { #entry .date-result-input { border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; padding: 0.85rem 1rem; font-size: 1rem; } }

#entry .date-widget:focus-within + .date-result-input { border-color: #3b82f6; background-color: #dbeafe; }

#entry .form-section { padding: 20px 15px; position: relative; }

@media (min-width: 768px) { #entry .form-section { padding: 40px; } }

#entry .section-header { 
    font-family: 'Moul', serif; 
    font-size: 1.1rem; 
    margin-bottom: 20px; 
    display: flex; align-items: center; gap: 10px; 
}

@media (min-width: 768px) { #entry .section-header { font-size: 1.25rem; margin-bottom: 25px; gap: 12px; } }

#entry .header-banner {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%); /* Richer Gradient */
    padding: 20px; color: white; text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) { #entry .header-banner { padding: 30px; } }

#entry .btn-copy {
    font-size: 0.7rem; background-color: #f0f9ff; color: #0284c7; 
    padding: 6px 12px; border-radius: 20px; font-weight: bold; 
    cursor: pointer; transition: all 0.2s; border: 1px solid #bae6fd;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    white-space: nowrap;
}

@media (min-width: 768px) { #entry .btn-copy { font-size: 0.75rem; padding: 8px 16px; } }
#entry .btn-copy:hover { background-color: #e0f2fe; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

/* Zigzag Separator Colors */
#entry .zigzag-separator {
    height: 10px; width: 100%; position: relative; margin-bottom: 25px;
    background: 
        linear-gradient(135deg, #fff 6px, transparent 0) 0 6px,
        linear-gradient(225deg, #fff 6px, transparent 0) 0 6px,
        linear-gradient(315deg, #fff 6px, transparent 0) 0 0,
        linear-gradient(45deg, #fff 6px, transparent 0) 0 0;
    background-color: var(--z-color);
    background-size: 12px 12px;
    opacity: 0.6;
}
#entry .z-orange { --z-color: #f97316; }
#entry .z-blue { --z-color: #2563eb; }
#entry .z-pink { --z-color: #ec4899; }
#entry .z-green { --z-color: #10b981; }

/* Modal Styles */
#entry .custom-modal {
    display: none; position: fixed; z-index: 1000; inset: 0;
    background-color: rgba(15, 23, 42, 0.7); backdrop-filter: blur(5px);
    align-items: center; justify-content: center; padding: 20px;
}

#entry .modal-card {
    background-color: white; padding: 25px; border-radius: 20px;
    text-align: center; width: 100%; max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid #f1f5f9;
}

@media (min-width: 768px) { #entry .modal-card { padding: 35px; } }

#entry .modal-icon-circle {
    width: 60px; height: 60px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 15px auto;
}

#entry .modal-success .modal-icon-circle { background-color: #dcfce7; color: #16a34a; }
#entry .modal-confirm .modal-icon-circle { background-color: #fee2e2; color: #dc2626; }
#entry .modal-alert .modal-icon-circle { background-color: #fef9c3; color: #ca8a04; }

#entry .parents-banner {
    text-align: center; margin-bottom: 20px; position: relative; z-index: 1;
}

#entry .parents-banner-text {
    display: inline-block;
    padding: 10px 25px;
    border-radius: 50px;
    font-family: 'Moul', serif;
    font-size: 0.95rem; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    border-width: 2px;
    background-color: white;
}
#entry .parents-banner::before {
    content: ""; position: absolute; top: 50%; left: 0;
    width: 100%; height: 1px; background-color: #cbd5e1; z-index: -1;
}
#entry .modal-alert .modal-icon-circle { background-color: #fef9c3; color: #ca8a04; }

/* Fixed: Simplified selector to ensure it works */
#loading-overlay {
    display: none; position: fixed; inset: 0; background: rgba(255,255,255,0.95);
    z-index: 2000; align-items: center; justify-content: center; flex-direction: column;
    backdrop-filter: blur(4px);
}

#entry .parents-banner {
    text-align: center; margin-bottom: 20px; position: relative; z-index: 1;
}