/* --- 1. THEME VARIABLES --- */
:root {
    /* Light Mode */
    --bg-body: #fdfcf8;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.8);
    --card-hover: rgba(255, 255, 255, 0.95);
    --shadow: rgba(0,0,0,0.04);

    --accent-1: #ff9a9e; /* Peach */
    --accent-2: #a18cd1; /* Lavender */
    --danger: #ff7675;
    --success: #00b894;
    --marquee-bg: rgba(255,255,255,0.5);
}

/* Dark Mode */
body.dark-mode {
    --bg-body: #1e272e;
    --text-main: #f5f6fa;
    --text-muted: #b2bec3;
    --glass-bg: rgba(30, 39, 46, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-hover: rgba(30, 39, 46, 0.9);
    --shadow: rgba(0,0,0,0.4);
    --marquee-bg: rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-body);
    background-image:
        radial-gradient(circle at 10% 10%, rgba(255, 154, 158, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 20%, rgba(161, 140, 209, 0.1) 0%, transparent 40%);
    background-attachment: fixed;
    min-height: 100vh;
    font-family: 'Poppins', sans-serif;
    color: var(--text-main);
    display: flex; flex-direction: column; align-items: center;
    padding-bottom: 50px;
    transition: background-color 0.3s ease;
    overflow-x: hidden;
}

/* --- 2. ADMIN TOGGLES (CSS LOGIC) --- */
/* By default, hide admin elements */
.admin-only { display: none !important; }

/* If body has 'is-admin' class, show them */
body.is-admin .admin-only { display: flex !important; }

/* --- 3. HEADER --- */
header {
    width: 100%; max-width: 1400px;
    margin-top: 40px; text-align: center;
    display: flex; flex-direction: column; align-items: center;
}

.header-top {
    display: flex; justify-content: center; align-items: center; position: relative; width: 100%;
}

h1 {
    font-family: 'Sekuya', script;
    font-size: 4.0rem; font-weight: 700; letter-spacing: 0px;
    color: var(--text-main);
}


/* ADD THIS to fix the header alignment */
.title-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px; /* Gives space before the controls */
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: -6px; /* Tucks it closer to the H1 */
    letter-spacing: 1px;
}
.top-actions {
    position: absolute; right: 20px; top: 0;
    display: flex; gap: 10px;
}

.icon-toggle {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    width: 40px; height: 40px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-main); transition: 0.3s;
}
.icon-toggle:hover { transform: rotate(15deg); background: var(--card-hover); }

/* Login Button Specifics */
.login-btn-header {
    padding: 0 20px; border-radius: 30px; width: auto;
    font-weight: 600; font-family: 'Montserrat', sans-serif;
    font-size: 0.85rem;
}

/* MARQUEE */
.marquee-container {
    width: 100%; max-width: 1000px;
    margin: 20px 0 30px 0;
    background: var(--marquee-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50px; overflow: hidden; padding: 8px 0;
    backdrop-filter: blur(10px);
}
.marquee-content { display: flex; gap: 30px; white-space: nowrap; animation: scroll 25s linear infinite; }
.marquee-content:hover { animation-play-state: paused; }
.marquee-item {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.1); padding: 5px 15px; border-radius: 20px;
    color: var(--text-main); text-decoration: none; font-size: 0.85rem; font-weight: 600;
    border: 1px solid var(--glass-border); transition: 0.2s; cursor: pointer;
}
.marquee-item:hover { background: var(--accent-2); color: white; border-color: transparent; }
.marquee-item i { color: var(--danger); font-size: 0.8rem; }
@keyframes scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

/* CONTROLS */
.controls-row {
    display: flex; gap: 12px; flex-wrap: wrap;
    justify-content: center; width: 100%; max-width: 1000px;
    margin-bottom: 40px;
}
#searchBar {
    flex: 1; min-width: 260px; padding: 14px 25px;
    font-size: 1rem; border-radius: 50px;
    border: 2px solid var(--accent-2);
    background: var(--glass-bg); color: var(--text-main);
    backdrop-filter: blur(15px); outline: none; transition: 0.3s;
    margin-left: 4px;
    overflow: hidden;
}
#searchBar:focus { background: var(--card-hover); border-color: var(--accent-1); shadow: 0 5px 15px rgba(161, 140, 209, 0.3); border-width: 2px; blur: 20px; box-shadow: 0 8px 30px rgba(161, 140, 209, 0.2); }

.action-btn {
    padding: 14px 22px; border-radius: 50px; border: none;
    color: white; font-weight: 600; cursor: pointer;
    font-family: 'Montserrat', sans-serif; transition: 0.3s;
    display: flex; align-items: center; gap: 8px;
}
.btn-add { background: linear-gradient(135deg, var(--accent-1), #fad0c4); }
.btn-export { background: linear-gradient(135deg, var(--accent-2), #a18cd1); }
.btn-view { background: var(--glass-bg); color: var(--text-main); border: 1px solid var(--glass-border); }
.action-btn:hover { transform: translateY(-3px); opacity: 0.9; }

/* --- 4. GRID & CARDS --- */
.grid-container {
    display: grid;
    /* responsive grid columns */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    width: 100%;
    max-width: 1400px;
    padding: 0 20px;
    margin: 0 auto; /* This centers the container */
    transition: all 0.3s ease;
}

/* --- LIST VIEW OVERRIDES --- */
.grid-container.list-view {
    /* Force single column */
    grid-template-columns: 1fr;
    max-width: 900px; /* Constrain width for readability in list mode */
}

.grid-container.list-view .card {
    flex-direction: row; /* Image left, text right */
    height: 220px; /* Fixed height for list items */
    align-items: center;
}

.grid-container.list-view .card-image {
    width: 240px;
    height: 100%;
    margin: 0 20px 0 0;
    margin-bottom: 0; /* Remove default bottom margin */
    border-radius: 12px 0 0 12px; /* Smooth corners on left only */
}

/* --- MOBILE RESPONSIVENESS FOR LIST VIEW --- */
@media (max-width: 768px) {
    /* On mobile, even "List View" should stack vertically so it fits */
    .grid-container.list-view .card {
        flex-direction: column;
        height: auto;
    }
    .grid-container.list-view .card-image {
        width: 100%;
        height: 200px;
        margin: 0 0 15px 0;
        border-radius: 12px;
    }
}

/* --- CARD STYLING (Shared) --- */
.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 15px;
    /* Default Grid Height */
    height: 530px;
    display: flex;
    flex-direction: column;
    position: relative;
    backdrop-filter: blur(15px);
    box-shadow: 0 10px 30px var(--shadow);
    transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.card:hover {
    transform: translateY(-8px);
    background: var(--card-hover);
}

/* Actions (Edit/Delete) */
.card-actions {
    position: absolute; top: 15px; right: 15px; z-index: 10;
    display: flex; gap: 8px;
}

.icon-btn {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s; color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.btn-del { background: rgba(255, 118, 117, 0.9); }
.btn-edit { background: rgba(253, 203, 110, 0.9); }
.icon-btn:hover { transform: scale(1.15); }

/* Content Styling */
.card-image {
    width: 100%; height: 200px; object-fit: cover; border-radius: 12px;
    margin-bottom: 15px; background: #ddd;
}
.card-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; width: 100%; }
.card-title {
    font-size: 1.2rem; font-weight: 700; color: var(--text-main);
    margin-bottom: 5px; line-height: 1.3;
}
.date-badge { font-size: 0.8rem; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 5px; }
.desc-label { font-size: 0.7rem; font-weight: 700; color: var(--accent-2); text-transform: uppercase; margin-bottom: 5px; }
.card-desc {
    font-size: 0.9rem; color: var(--text-muted); line-height: 1.6;
    margin-bottom: 15px; overflow-y: auto; flex-grow: 1;
}

.work-btn {
    display: block; width: 100%; padding: 12px; text-align: center;
    text-decoration: none; color: var(--text-main); font-weight: 600;
    border: 1px solid var(--glass-border); border-radius: 12px;
    transition: 0.3s; margin-top: auto;
}
.work-btn:hover {
    background: linear-gradient(135deg, var(--accent-1), #fecfef);
    color: white; border-color: transparent;
}

/* --- 5. PAGINATION --- */
.pagination {
    margin: 40px 0; display: flex; gap: 15px; align-items: center;
    background: var(--glass-bg); padding: 8px 25px; border-radius: 50px;
}
.page-btn {
    background: var(--bg-body); border: 1px solid var(--glass-border);
    color: var(--text-main); padding: 8px 18px; border-radius: 30px;
    cursor: pointer; transition: 0.2s; font-weight: 600;
}
.page-btn:hover:not(:disabled) { background: var(--text-main); color: var(--bg-body); }
.page-btn:disabled { opacity: 0.5; cursor: default; }

/* --- 6. MODALS --- */
.modal {
    display: none; position: fixed; z-index: 2000; left: 0; top: 0;
    width: 100%; height: 100%; background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px); align-items: center; justify-content: center; padding: 20px;
}
.modal-content {
    background: var(--bg-body); color: var(--text-main);
    padding: 30px; border-radius: 24px; width: 100%; max-width: 450px;
    position: relative; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.4); animation: zoomIn 0.3s ease;
}
@keyframes zoomIn { from {transform: scale(0.95); opacity: 0;} to {transform: scale(1); opacity: 1;} }
.close-modal { position: absolute; right: 20px; top: 20px; font-size: 1.5rem; cursor: pointer; }

.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.9rem; }
.form-group input, .form-group textarea {
    width: 100%; padding: 12px; border: 1px solid #ccc;
    border-radius: 8px; background: rgba(255,255,255,0.05);
    color: var(--text-main); margin-bottom: 15px; outline: none;
}
.submit-btn {
    width: 100%; padding: 14px; background: var(--text-main);
    color: var(--bg-body); border: none; border-radius: 12px;
    font-weight: 700; cursor: pointer;
}

/* LOGIN SPECIFIC */
.login-note { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 20px; text-align: center; }

/* Toast */
#toast-container { position: fixed; bottom: 30px; right: 30px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--bg-body); color: var(--text-main);
    padding: 12px 25px; border-radius: 12px; font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease; border-left: 5px solid; display: flex; align-items: center; gap: 10px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn { from{transform:translateX(100%)} to{transform:translateX(0)} }

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem; /* Smaller font on mobile */
    }

    .header-top {
        flex-direction: column;
        gap: 15px;
    }

    .top-actions {
        position: relative; /* Stops it from floating over text on mobile */
        right: auto;
        top: auto;
        margin-bottom: 10px;
    }
}

/* --- WELCOME SCREEN (Google Inspired) --- */
#welcome-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100vh;
    background-color: #ffffff; /* Clean White */
    z-index: 9999; /* Sit on top of everything */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s;
}

/* Dark mode support for welcome screen */
body.dark-mode #welcome-screen {
    background-color: #202124; /* Google Dark Mode Grey */
}

.brand-container { text-align: center; }

/* The Google Colors */
.g-blue { color: #4285F4; }
.g-red { color: #DB4437; }
.g-yellow { color: #F4B400; }
.g-green { color: #0F9D58; }

.welcome-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    font-weight: 600;
    margin-top: 20px;
    letter-spacing: -1px;
}
.welcome-sub {
    font-family: 'Montserrat', sans-serif;
    color: #5f6368;
    font-size: 1rem;
    margin-top: 0px;
    opacity: 0;
    animation: fadeUp 0.8s ease-out forwards 0.5s;
}

/* Bouncing Dots Animation */
.google-loader {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.dot {
    width: 18px; height: 18px;
    border-radius: 50%;
    animation: bounce 1.5s infinite ease-in-out;
}

.dot.blue { background-color: #4285F4; animation-delay: 0s; }
.dot.red { background-color: #DB4437; animation-delay: 0.1s; }
.dot.yellow { background-color: #F4B400; animation-delay: 0.2s; }
.dot.green { background-color: #0F9D58; animation-delay: 0.3s; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Class to hide the screen */
.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Allows clicking through while fading */
}