/* --- 1. General Reset & Base Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    width: 100%;
    overflow-x: hidden;
    background-color: #f4f7f9;
}

body {
    display: flex;
    min-height: 100vh;
}

/* --- 2. Sidebar (Fixed & Scrollable) --- */
.sidebar {
    width: 260px;
    background: #1a1c23;
    color: white;
    padding: 20px;
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    height: 100vh;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: #4f46e5;
    border-radius: 10px;
}

.logo h2 {
    color: #4f46e5;
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.nav-links {
    list-style: none;
}
.nav-links li {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: 0.2s;
    cursor: pointer;
    color: #a0aec0;
}
.nav-links li.active, .nav-links li:hover {
    background: #4f46e5;
    color: white;
}
.nav-links a {
    color: inherit;
    text-decoration: none;
    display: block;
    width: 100%;
}

/* --- 3. Auth & User Profile Boxes --- */
.auth-sidebar-box, .user-sidebar-box {
    background: #2a2d37;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 25px;
    flex-shrink: 0;
}

.auth-sidebar-box h3 {
    font-size: 0.8rem;
    margin-bottom: 10px;
    color: #4f46e5;
    text-transform: uppercase;
}
.auth-sidebar-box input {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    background: #1a1c23;
    border: 1px solid #3f3f46;
    color: white;
    border-radius: 4px;
}

.auth-btn, .logout-btn {
    width: 100%;
    padding: 10px;
    background: #4f46e5;
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.logout-btn {
    background: #3f3f46;
    margin-top: 10px;
}
.auth-footer {
    font-size: 0.85rem;
    margin-top: 18px;
    text-align: center;
    color: #cbd5e0;
}
.auth-footer a {
    color: #a5b4fc;
    text-decoration: underline;
    font-weight: 600;
}
.user-name {
    font-weight: bold;
    color: #fff;
    display: block;
    margin-bottom: 5px;
}

/* --- 4. Main Content Area --- */
.main-content {
    margin-inline-start: 260px;
    padding: 40px;
    flex: 1;
    min-width: 0;
    transition: margin-inline-start 0.3s ease;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

/* --- 5. Landing View (Logged Out) --- */
.dashboard-content {
    display: none;
}
body.is-logged-in .dashboard-content {
    display: block;
}
body.is-logged-in .landing-view {
    display: none;
}

.hero-section {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f4ff 100%);
    border-radius: 20px;
    margin-bottom: 40px;
    border: 1px solid #e2e8f0;
}

.hero-section h1 {
    font-size: 2.5rem;
    color: #1a1c23;
    margin-bottom: 15px;
}
.hero-section .accent {
    color: #4f46e5;
}
.hero-section p {
    color: #64748b;
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}
.feature-card {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    transition: 0.3s ease;
    border: 1px solid #f1f5f9;
}
.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    border-color: #4f46e5;
}
.feature-card .icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
}
.feature-card h3 {
    color: #1a1c23;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

/* --- 6. Shopping List System --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.list-card {
    cursor: pointer;
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.25s ease;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
}
.list-card:hover {
    border-color: #4f46e5;
    transform: translateY(-4px);
    box-shadow: 0 12px 20px rgba(0,0,0,0.08);
}

.list-card .list-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.list-title {
    font-size: 1.2rem;
    color: #1a1c23;
    margin-bottom: 20px;
    flex-grow: 1;
}

.type-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}
.badge-blue {
    background: #e0e7ff;
    color: #4338ca;
}
.badge-grey {
    background: #f1f5f9;
    color: #475569;
}
.item-count {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
}

/* Integrated Footer Styles */
.list-card-footer, .footer-flex {
    border-top: 1px solid #f1f5f9;
    padding-top: 12px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    font-size: 0.8rem;
}

.date-group {
    display: flex;
    gap: 5px;
}
.date-label {
    color: #94a3b8;
    font-weight: 500;
}
.date-value {
    color: #64748b;
    font-weight: 600;
}

/* --- 7. Single List Table & States --- */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.items-table th {
    text-align: inline-start;
    font-size: 0.8rem;
    color: #64748b;
    padding: 10px;
    border-bottom: 2px solid #f1f5f9;
    text-transform: uppercase;
}
.items-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
    vertical-align: middle;
}

.action-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: 0.2s;
    margin-inline-start: 5px;
    text-transform: uppercase;
}
.btn-taken {
    background-color: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}
.btn-notfound {
    background-color: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.notes-row td {
    border-bottom: 2px solid #f1f5f9 !important;
    padding-top: 0 !important;
    color: #94a3b8;
    font-size: 0.8rem;
    font-style: italic;
}

.row-taken tr td {
    text-decoration: line-through;
    font-style: italic;
    color: #94a3b8;
}
.row-taken .action-btn {
    opacity: 0.5;
}

.row-notfound tr td:first-child {
    border-inline-start: 4px solid #dc2626;
    color: #dc2626;
}
.row-notfound .btn-notfound {
    background-color: #dc2626;
    color: white;
}

/* --- 8. Small Icon Buttons (Edit/Delete) --- */
.edit-icon-btn, .delete-icon-btn {
    border: none;
    padding: 4px 10px;
    margin: 0 2px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.edit-icon-btn {
    background: #f1f5f9;
    color: #4f46e5;
}
.edit-icon-btn:hover {
    background: #e0e7ff;
    color: #4338ca;
    transform: translateY(-1px);
}

.delete-icon-btn {
    background: #fef2f2;
    color: #dc2626;
}
.delete-icon-btn:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* --- 9. General UI Components & Modals --- */
.card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);

}

.card h3 {
    margin-bottom: 15px;
    color: #666;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-link-styled {
    display: block;
    width: 100%;
    max-width: 200px;
    padding: 12px;
    background: #4f46e5;
    color: white !important;
    text-decoration: none !important;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}
.btn-link-styled:hover {
    background: #4338ca;
}

.modal {
    position: fixed;
    top:0;
    left:0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-content {
    width: 90%;
    max-width: 400px;
    padding: 30px;
}

.back-link {
    text-decoration: none;
    color: #4f46e5;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 5px;
    display: block;
}

.link-reset {
    text-decoration: none !important;
    color: inherit !important;
    display: inline-block;
}

/* --- 10. Auth Forms & Item Creator --- */
.auth-style-card {
    transition: all 0.25s ease;
    border: 1px solid transparent;
    max-width: 400px;
    margin: 40px auto;
}
.auth-style-card:hover {
    border-color: #4f46e5;
    transform: translateY(-4px);
    box-shadow: 0 12px 20px rgba(0,0,0,0.08);
}
.auth-style-card h3 {
    text-align: center;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 20px;
}
.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 8px;
    text-transform: uppercase;
}
.auth-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: 0.2s;
    background: #ffffff;
}
.auth-input:focus {
    border-color: #4f46e5;
    outline: none;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.item-creator {
    margin-bottom: 30px;
    margin-top: 20px;
}
.item-form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.grid-span-2 {
    grid-column: span 2;
}
.grid-span-4 {
    grid-column: span 4;
}
.grid-column-1 {
    grid-column: span 1;
}

.select-style {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 1em;
    padding-inline-end: 30px !important;
    cursor: pointer;
    color: #64748b;
}

/* --- 11. Responsive (Mobile) --- */
.mobile-header {
    display: none;
    background: #1a1c23;
    color: white;
    padding: 15px 20px;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1100;
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    .mobile-header {
        display: flex;
    }
    .desktop-only {
        display: none;
    }
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 0;
        position: fixed;
        top: 60px;
        inset-inline-start: 0;
        padding: 0 20px;
        opacity: 0;
    }
    .sidebar.active {
        max-height: calc(100vh - 60px);
        padding: 20px;
        opacity: 1;
    }
    .main-content {
        margin-inline-start: 0;
        padding: 20px;
    }

    /* Mobile Table Stacking */
    .items-table thead {
        display: none;
    }
    .items-table tbody {
        display: block;
        margin-bottom: 15px;
        border-bottom: 2px solid #f1f5f9;
        padding-bottom: 10px;
    }
    .items-table tr {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        border: none;
    }
    .item-name {
        flex: 1;
        border: none !important;
    }
    .item-qty {
        width: auto;
        text-align: end;
        border: none !important;
    }
    .item-actions {
        display: flex;
        width: 100%;
        justify-content: flex-start;
        padding-top: 10px !important;
        border: none !important;
        order: 3;
    }
    .notes-row {
        display: block;
        width: 100%;
        order: 2;
    }
    .notes-row td {
        display: block;
        width: 100%;
        border: none !important;
        padding: 5px 10px !important;
    }

    .item-form-grid {
        grid-template-columns: 1fr;
    }
    .grid-span-2, .grid-span-4, .grid-column-1 {
        grid-column: span 1;
    }
}

/* --- 12. Alert & Validation Styles --- */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-danger {
    background-color: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.alert-success {
    background-color: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}

.error-text {
    color: #dc2626;
    font-size: 0.75rem;
    margin-top: -15px;
    margin-bottom: 15px;
    display: block;
    font-weight: 600;
}

/* --- 13. AJAX Loading States --- */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.btn-loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: wait;
}

/* --- 14. RTL Specific Overrides --- */
[dir="rtl"] .select-style {
    background-position: left 10px center;
    padding-inline-end: 12px !important;
    padding-inline-start: 30px !important;
}

[dir="rtl"] .items-table th,
[dir="rtl"] .items-table td {
    text-align: right;
}

[dir="rtl"] .row-notfound tr td:first-child {
    border-inline-start: none;
    border-inline-end: 4px solid #dc2626;
}

/* --- 15. Language Selection & Icons --- */
.sidebar-header-with-icon {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.lang-icon {
    color: #4f46e5; /* Matches your accent color */
    margin-inline-end: 8px; /* Logical: right in LTR, left in RTL */
}

.lang-button-group {
    display: flex;
    gap: 8px;
}

.lang-btn {
    flex: 1;
    padding: 8px 5px;
    background: #1a1c23;
    border: 1px solid #3f3f46;
    color: #a0aec0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.2s ease;
    text-align: center;
    text-decoration: none;
    display: block;
}

.lang-btn:hover {
    border-color: #4f46e5;
    color: white;
}

.lang-btn.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
    box-shadow: 0 0 10px rgba(79, 70, 229, 0.3);
}

[dir="rtl"] .lang-button-group {
    flex-direction: row;
}

/* --- 16. Site Footer --- */
.site-footer {
    margin-top: 20px; /* Changed from auto to fixed 20px */
    padding: 20px 0;
    border-top: 1px solid #e2e8f0;
    color: #94a3b8;
    font-size: 0.85rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #4f46e5;
}

/* RTL Adjustment */
[dir="rtl"] .footer-content {
    flex-direction: row;
}

/* --- 17. Career Module Extensions (Updated) --- */
.main-header-bordered {
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px; /* Increased gap for better balance */
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
}

/* Base button class to ensure equal sizing */
.btn-base {
    padding: 10px 25px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    min-width: 140px; /* Ensures buttons are same width even with different text lengths */
    text-align: center;
}

.btn-cancel {
    background: white;
    border-color: #cbd5e1;
    color: #64748b;
}

.btn-cancel:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

/* Primary action override */
.btn-save-primary {
    background: #4f46e5;
    color: white;
}

.btn-save-primary:hover {
    background: #4338ca;
}

.textarea-styled {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}