/* --- Base & Variables (Unified Theme) --- */
:root {
    /* Light Theme Colors */
    --bg-light: #f8f9fa;
    --card-bg-light: #ffffff;
    --text-light: #212529;
    --text-muted-light: #6c757d;
    --border-light: #dee2e6;
    --input-bg-light: #ffffff;
    --header-bg-light: rgba(255, 255, 255, 0.85);
    --nav-drawer-bg-light: #f8f9fa;
    --shadow-light: rgba(0, 0, 0, 0.08);

    /* Dark Theme Colors */
    --dark-bg: #121212;
    --card-bg-dark: #1e1e1e;
    --text-dark: #f5f5f5;
    --text-muted-dark: #aaa;
    --border-dark: #444;
    --input-bg-dark: #2a2a2a;
    --header-bg-dark: rgba(18, 18, 18, 0.85);
    --nav-drawer-bg-dark: var(--card-bg-dark);
    --shadow-dark: rgba(0, 0, 0, 0.25);

    /* Shared Accent Colors */
    --primary-color: #8A2BE2;
    --primary-hover: #7B1FA2;
    --error-color: #dc3545;
    --success-color: #198754;
    --shadow-color-primary: rgba(138, 43, 226, 0.2);

    /* Global Font & Transitions */
    --font-family: 'Poppins', sans-serif;
    --transition-speed: 0.3s;
    --border-radius: 8px;
    --header-height: 65px;

    /* Default Theme (Dark) */
    --current-bg: var(--dark-bg);
    --current-card-bg: var(--card-bg-dark);
    --current-text: var(--text-dark);
    --current-text-muted: var(--text-muted-dark);
    --current-border: var(--border-dark);
    --current-input-bg: var(--input-bg-dark);
    --current-header-bg: var(--header-bg-dark);
    --current-nav-drawer-bg: var(--nav-drawer-bg-dark);
    --current-shadow: var(--shadow-dark);
    color-scheme: dark;
}

/* Light Theme Overrides */
html.light-theme {
    --current-bg: var(--bg-light);
    --current-card-bg: var(--card-bg-light);
    --current-text: var(--text-light);
    --current-text-muted: var(--text-muted-light);
    --current-border: var(--border-light);
    --current-input-bg: var(--input-bg-light);
    --current-header-bg: var(--header-bg-light);
    --current-nav-drawer-bg: var(--nav-drawer-bg-light);
    --current-shadow: var(--shadow-light);
    color-scheme: light;
}

/* --- Global & Base Styles --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; height: 100%; }
body { font-family: var(--font-family); background-color: var(--current-bg); color: var(--current-text); line-height: 1.6; font-weight: 300; min-height: 100%; display: flex; flex-direction: column; overflow-x: hidden; }
h1, h2, h3, h4 { font-weight: 600; margin-top: 0; line-height: 1.3; }
a { color: var(--primary-color); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; display: block; }

/* --- Navigation Styles (Consistent) --- */
.header { background-color: var(--current-header-bg); backdrop-filter: blur(10px); position: fixed; top: 0; left: 0; width: 100%; z-index: 1000; border-bottom: 1px solid var(--current-border); height: var(--header-height); }
.header-container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; display: flex; justify-content: space-between; align-items: center; height: 100%; }
.header-left { display: flex; align-items: center; }
.menu-btn { background: none; border: none; padding: 0.5rem; margin-right: 1rem; cursor: pointer; z-index: 1101; }
.menu-btn .bar { display: block; width: 25px; height: 3px; background-color: var(--current-text); margin: 5px auto; transition: all 0.3s ease-in-out; border-radius: 3px; }
.menu-btn.active .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-btn.active .bar:nth-child(2) { opacity: 0; }
.menu-btn.active .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
.app-logo { display: flex; align-items: center; text-decoration: none; }
.logo-icon { color: var(--primary-color); font-size: 1.8rem; margin-right: 0.5rem; }
.app-title { font-size: 1.5rem; font-weight: 600; margin: 0; color: var(--current-text); }
.header-right { display: flex; align-items: center; gap: 1rem; }
.theme-switch { position: relative; display: inline-block; width: 50px; height: 26px; cursor: pointer; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #444; transition: var(--transition-speed); border-radius: 26px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: var(--transition-speed); border-radius: 50%; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(24px); }
.slider-icon { position: absolute; top: 50%; transform: translateY(-50%); font-size: 0.8rem; opacity: 0.7; }
.slider-icon.light { left: 6px; color: #f1c40f; opacity: 0; }
.slider-icon.dark { right: 6px; color: #bdc3c7; }
input:checked ~ .slider .slider-icon.light { opacity: 1; }
input:checked ~ .slider .slider-icon.dark { opacity: 0; }
html.light-theme .slider { background-color: #ccc; }
.profile-link { color: var(--current-text-muted); font-size: 1.6rem; transition: color var(--transition-speed) ease; }
.profile-link:hover, .profile-link.active { color: var(--primary-color); }
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); z-index: 1099; opacity: 0; visibility: hidden; transition: opacity var(--transition-speed) ease; }
.overlay.active { opacity: 1; visibility: visible; }
.nav-drawer { position: fixed; top: 0; left: 0; height: 100%; width: 280px; background-color: var(--current-nav-drawer-bg); z-index: 1100; transform: translateX(-100%); transition: transform 0.35s ease; box-shadow: 5px 0px 15px var(--current-shadow); display: flex; flex-direction: column; }
.nav-drawer.active { transform: translateX(0); }
.nav-drawer-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--current-border); }
.nav-drawer-title { margin: 0; font-size: 1.3rem; }
.nav-drawer ul { list-style: none; padding: 1rem 0; margin: 0; flex-grow: 1; }
.nav-link { display: flex; align-items: center; padding: 0.9rem 1.5rem; color: var(--current-text-muted); text-decoration: none; font-weight: 400; border-left: 3px solid transparent; }
.nav-link:hover, .nav-link.active-page { background-color: rgba(138, 43, 226, 0.1); color: var(--primary-color); border-left-color: var(--primary-color); }
.nav-icon { margin-right: 1rem; width: 20px; text-align: center; color: var(--primary-color); }
.nav-footer { margin-top: auto; padding: 1rem 1.5rem; border-top: 1px solid var(--current-border); }
.btn-logout { width: 100%; }
body.nav-open { overflow: hidden; }

/* --- Main Content Area --- */
.view-items-main { padding-top: var(--header-height); flex-grow: 1; }
.main-content-container { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }
.page-header { text-align: center; margin-bottom: 2.5rem; }
.page-title { font-size: 2.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.page-subtitle { font-size: 1.1rem; color: var(--current-text-muted); max-width: 800px; margin: 0 auto; }

/* --- Controls Section --- */
.controls-section { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: 2rem; background-color: var(--current-card-bg); padding: 1rem; border-radius: var(--border-radius); border: 1px solid var(--current-border); }
.search-wrapper { position: relative; flex-grow: 1; min-width: 250px; }
.search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--current-text-muted); }
.search-bar { width: 100%; padding: 0.75rem 1rem 0.75rem 40px; font-size: 1rem; background-color: var(--current-input-bg); color: var(--current-text); border: 1px solid var(--current-border); border-radius: var(--border-radius); outline: none; transition: all var(--transition-speed) ease; }
.search-bar:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--shadow-color-primary); }
.sort-wrapper { display: flex; align-items: center; gap: 0.75rem; }
.sort-label { font-size: 0.9rem; color: var(--current-text-muted); font-weight: 500; }
.sort-select { padding: 0.7rem 1rem; font-size: 0.95rem; background-color: var(--current-input-bg); color: var(--current-text); border: 1px solid var(--current-border); border-radius: var(--border-radius); cursor: pointer; }

/* --- Items List Section --- */
.items-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; min-height: 150px; position: relative; }
.item-card { background-color: var(--current-card-bg); border-radius: var(--border-radius); overflow: hidden; border: 1px solid var(--current-border); cursor: pointer; display: flex; flex-direction: column; opacity: 0; transform: translateY(20px); transition: transform 0.4s ease, box-shadow 0.4s ease, border-color 0.4s ease, opacity 0.5s ease-out; }
.item-card.is-visible { opacity: 1; transform: translateY(0); }
.item-card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px var(--current-shadow); border-color: var(--primary-color); }
.item-image-wrapper { width: 100%; height: 180px; overflow: hidden; }
.item-image-wrapper img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.item-card:hover .item-image-wrapper img { transform: scale(1.05); }
.item-info { padding: 1.25rem; display: flex; flex-direction: column; flex-grow: 1; }
.item-info h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.3rem; }
.item-description { font-size: 0.9rem; color: var(--current-text-muted); margin-bottom: 1rem; flex-grow: 1; }
.item-meta { font-size: 0.85rem; color: var(--current-text-muted); margin-top: auto; padding-top: 1rem; border-top: 1px dashed var(--current-border); display: flex; justify-content: space-between; align-items: center; }
.item-meta i { margin-right: 0.4rem; color: var(--primary-color); }

/* --- Loading & Messages --- */
.loading-indicator { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: none; justify-content: center; align-items: center; flex-direction: column; color: var(--current-text-muted); }
.loading-indicator.show { display: flex; }
.spinner.large { width: 40px; height: 40px; border-width: 4px; border-color: rgba(170, 170, 170, 0.3); border-top-color: var(--current-text-muted); margin-bottom: 1rem; animation: spin 1.5s linear infinite; border-radius: 50%; }
@keyframes spin { to { transform: rotate(360deg); } }
.no-items-message { grid-column: 1 / -1; text-align: center; color: var(--current-text-muted); padding: 4rem 1rem; }
.no-items-message i { display: block; font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.form-message { padding: 0.8rem 1rem; border-radius: var(--border-radius); font-size: 0.9rem; margin-bottom: 1rem; text-align: center; display: none; border-left: 4px solid transparent; }
.form-message.show { display: block; }
.form-message.error { background-color: rgba(220, 53, 69, 0.1); color: var(--error-color); border-left-color: var(--error-color); }
.form-message.success { background-color: rgba(25, 135, 84, 0.1); color: var(--success-color); border-left-color: var(--success-color); }

/* --- Modal Styles --- */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; background-color: rgba(0,0,0,0.85); z-index: 9999; opacity: 0; visibility: hidden; transition: opacity var(--transition-speed) ease; }
.modal.active { opacity: 1; visibility: visible; }
.modal-content { position: relative; background-color: var(--current-card-bg); border-radius: var(--border-radius); padding: 2rem; max-width: 600px; width: 90%; max-height: 85vh; overflow-y: auto; transform: scale(0.95); transition: transform var(--transition-speed) ease; }
.modal.active .modal-content { transform: scale(1); }
.close-btn { position: absolute; top: 1rem; right: 1rem; font-size: 1.8rem; font-weight: bold; cursor: pointer; background: none; border: none; color: var(--current-text-muted); }
.close-btn:hover { color: var(--primary-color); }
.modal-image { width: 100%; height: auto; max-height: 300px; object-fit: contain; margin-bottom: 1.5rem; border-radius: var(--border-radius); }
.modal-title { font-size: 1.6rem; margin-bottom: 1.5rem; color: var(--primary-color); }
.modal-details { border-top: 1px solid var(--current-border); padding-top: 1rem; font-size: 0.9rem; }
.modal-details p { margin-bottom: 0.75rem; }
.modal-details strong { font-weight: 600; color: var(--current-text); }
.modal-actions { margin-top: 1.5rem; display: flex; justify-content: flex-end; gap: 1rem; }

/* --- Edit Modal Form Styles --- */
.modal-form .input-group { margin-bottom: 1rem; }
.modal-form .input-group label { display: block; font-weight: 500; margin-bottom: 0.3rem; font-size: 0.9rem; }
.modal-form .input-group input,
.modal-form .input-group textarea,
.modal-form .input-group select {
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 1rem;
    background-color: var(--current-input-bg);
    color: var(--current-text);
    border: 1px solid var(--current-border);
    border-radius: var(--border-radius);
    outline: none;
    transition: all var(--transition-speed) ease;
}
.modal-form .input-group input:focus,
.modal-form .input-group textarea:focus,
.modal-form .input-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--shadow-color-primary);
}
.modal-form .input-group textarea { resize: vertical; }

/* --- General Button Styles --- */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.8rem 1.8rem; border-radius: var(--border-radius); font-weight: 500; font-size: 0.95rem; cursor: pointer; border: 1px solid transparent; transition: all var(--transition-speed) ease; text-transform: uppercase; letter-spacing: 0.5px; position: relative; }
.btn i { margin-right: 0.5rem; }
.btn-primary { background-color: var(--primary-color); color: #fff; }
.btn-primary:hover:not(:disabled) { background-color: var(--primary-hover); }
.btn-tertiary { background-color: transparent; color: var(--current-text-muted); border: 1px solid var(--current-border); }
.btn-tertiary:hover { background-color: rgba(138, 43, 226, 0.1); }
.btn:disabled { opacity: 0.65; cursor: not-allowed; }
.btn .spinner { display: none; position: absolute; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
.btn.loading .spinner { display: block; }
.btn.loading .btn-text { opacity: 0; }

/* --- Footer --- */
.footer { background-color: var(--current-card-bg); text-align: center; color: var(--current-text-muted); font-size: 0.9rem; padding: 1.5rem 1rem; border-top: 1px solid var(--current-border); margin-top: auto; }

/* --- Animations & Responsive --- */
.animate-on-load { opacity: 0; transition: opacity 0.8s ease-out, transform 0.8s ease-out; }
.fade-in { transform: translateY(20px); }
.animate-on-load.is-visible { opacity: 1; transform: translateY(0); }
.delay-1 { transition-delay: 0.2s; }
@media (max-width: 768px) {
    .controls-section { flex-direction: column; align-items: stretch; }
    .page-title { font-size: 2rem; }
}