/* ---------- FINALIZED CSS ---------- */
/* ---------- CSS Variables ---------- */
:root {
    --navy: #004080;
    --steel-blue: #187FC9;
    --bright-ocean: #1C93E8;
    --sky-blue: #65D1E2;
    --apricot: #FFCC85;
    --papaya: #FFEED6;
    --white: #FFFFFF;
    --error-red: #A3432B;
    --success-green: #1A7A4C;
    --text-dark: #003262;
    --text-body: #1B2A3A;
    --border-color: #C4A76C;
    --input-border: #B8A080;
    --shadow: rgba(0, 50, 98, 0.12);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--apricot);
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320'%3E%3Cpath fill='%23187FC9' fill-opacity='0.06' d='M0,288L48,272C96,256,192,224,288,213.3C384,203,480,213,576,229.3C672,245,768,267,864,261.3C960,256,1056,224,1152,208C1248,192,1344,192,1392,192L1440,192L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z'%3E%3C/path%3E%3C/svg%3E"), 
        radial-gradient(ellipse at 20% 50%, rgba(101, 209, 226, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(24, 127, 201, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 60% 80%, rgba(101, 209, 226, 0.12) 0%, transparent 50%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-body);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---------- Headers & Labels ---------- */
.app-title {
    text-align: center;
    color: var(--navy);
    font-size: 2.5rem;
    margin-top: 50px;
    letter-spacing: 1px;
}

h1 {
    color: var(--navy);
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 24px;
}

h2 {
    color: var(--navy);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
}

label {
    color: var(--navy);
    font-weight: 600;
    font-size: 0.95rem;
    display: block;
    margin-bottom: 6px;
}

/* ---------- Layout: Container ---------- */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* ---------- Auth Section (Login / Register) ---------- */
#auth-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    max-width: 100%;
}

#auth-section[style*="display: block"] {
    display: flex !important;
}

#auth-section[style*="display: none"] {
    display: none !important;
}

.auth-card {
    background-color: var(--papaya);
    max-width: 460px;
    width: 100%;
    padding: 40px 36px;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid rgba(0, 50, 98, 0.06);
}

.auth-card h1 {
    margin-bottom: 8px;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-body);
    background-color: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input::placeholder {
    color: #9A8A70;
}

.form-group input:focus {
    outline: none;
    border-color: var(--steel-blue);
    box-shadow: 0 0 0 3px rgba(24, 127, 201, 0.2);
}

/* ---------- Buttons ---------- */
.btn-primary,
.btn-secondary,
.btn-link {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background-color: var(--navy);
    color: var(--white);
    width: 100%;
    display: block;
    margin-top: 8px;
}

.btn-primary:hover {
    background-color: #004080;
    box-shadow: 0 2px 8px rgba(0, 50, 98, 0.3);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background-color: var(--error-red);
    color: var(--white) !important;
    width: 100%;
    display: block;
    margin-top: 8px;
}

.btn-secondary:hover {
    background-color: #8C3724;
    box-shadow: 0 2px 8px rgba(163, 67, 43, 0.3);
}

.btn-secondary:active {
    transform: scale(0.98);
}

#logout-btn {
    width: auto;
    padding: 10px 20px;
}

.btn-link {
    background: none;
    color: var(--sky-blue);
    text-decoration: underline;
    padding: 4px 8px;
    font-weight: 600;
    border-radius: 4px;
}

.btn-link:hover {
    color: var(--steel-blue);
    background-color: rgba(24, 127, 201, 0.08);
}

/* ---------- Toggle Auth (Login/Sign Up switch) ---------- */
.toggle-auth {
    text-align: center;
    margin-top: 24px;
    font-size: 0.95rem;
    color: var(--text-body);
}

/* ---------- Error Messages ---------- */
.error-msg {
    color: var(--error-red);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 16px;
    padding: 10px 14px;
    border-radius: 8px;
    background-color: rgba(163, 67, 43, 0.08);
    border: 1px solid rgba(163, 67, 43, 0.2);
    display: none;
}

.error-msg:not(:empty) {
    display: block;
}

/* ---------- Dashboard Section ---------- */
#dashboard-section {
    padding: 20px;
    max-width: 960px;
    margin: 0 auto;
}

/* ---------- Dashboard Header ---------- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(0, 50, 98, 0.1);
}

.dashboard-header h1 {
    text-align: left;
    margin-bottom: 0;
    font-size: 1.8rem;
}

/* ---------- Controls Section (Search + Add) ---------- */
.controls-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: nowrap;
}

.search-bar {
    flex: 1;
    min-width: 0;
}

.search-bar input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-body);
    background-color: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-bar input:focus {
    outline: none;
    border-color: var(--steel-blue);
    box-shadow: 0 0 0 3px rgba(24, 127, 201, 0.2);
}

.search-bar.form-group {
    margin-bottom: 0;
}

.controls-section .btn-primary {
    width: auto;
    flex-shrink: 0;
    padding: 12px 24px;
    margin-top: 0;
    display: inline-block;
}

/* ---------- Contacts Grid ---------- */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* ---------- Contact Card ---------- */
.contact-card {
    background-color: var(--papaya);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px var(--shadow);
    border: 1px solid rgba(0, 50, 98, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.contact-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 50, 98, 0.18);
}

.contact-card h3 {
    color: var(--navy);
    font-size: 1.15rem;
    margin-bottom: 8px;
}

.contact-card p {
    font-size: 0.9rem;
    color: var(--text-body);
    margin-bottom: 4px;
}

.contact-card .card-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.contact-card button {
    width: auto;
    display: inline-block;
}

.contact-card .card-actions button {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* ---------- Modal (Add/Edit Contact) ---------- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 50, 98, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal[aria-hidden="false"],
.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--papaya);
    max-width: 500px;
    width: 100%;
    padding: 36px 32px;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 50, 98, 0.25);
    border: 1px solid rgba(0, 50, 98, 0.06);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
    align-items: center;
}

.modal-actions .btn-secondary {
    width: auto;
    flex: 0 0 auto;
}

.modal-actions .btn-primary {
    width: auto;
    flex: 0 0 auto;
}

.modal-actions button {
    padding: 12px 24px;
    font-size: 1rem;
    min-width: 160px;
    height: 48px;
    border-radius: 8px;
}

/* ---------- Visually Hidden (Accessible) ---------- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .auth-card {
        padding: 28px 20px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .controls-section {
        flex-direction: column;
    }

    .controls-section .btn-primary {
        width: 100%;
    }

    .contacts-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 24px 20px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn-primary,
    .modal-actions .btn-secondary {
        width: 100%;
    }
}
