/* --- Modern Dribbble-Style Glassmorphism CSS --- */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    --secondary-color: #10b981; /* Emerald */
    --danger-color: #ef4444; /* Red */
    --danger-hover: #dc2626;
    --text-main: #1e293b;
    --text-muted: #64748b;
    
    /* Glassmorphism Variables */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    --glass-radius: 20px;
    
    --transition-speed: 0.3s;
}

body {
    font-family: 'Outfit', sans-serif;
    margin: 0;
    padding: 0;
    color: var(--text-main);
    background: linear-gradient(135deg, #f6f8fd 0%, #f1f5f9 100%);
    min-height: 100vh;
    box-sizing: border-box;
}

* { box-sizing: border-box; }

/* --- Application Layout --- */
.app-layout {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: var(--glass-border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 40px;
    text-decoration: none;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    border-radius: 12px;
    transition: all var(--transition-speed) ease;
}

.sidebar-nav-link:hover, .sidebar-nav-link.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.sidebar-nav-link i { font-size: 1.1rem; width: 20px; text-align: center; }

.logout-wrapper {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}
.profile-avatar {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    transition: all var(--transition-speed);
}
.profile-avatar:hover {
    color: var(--primary-color);
}
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    text-decoration: none;
    color: var(--danger-color);
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.1);
    transition: all var(--transition-speed);
}
.sidebar-logout:hover {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

/* --- Main Content Area --- */
.main-content {
    flex-grow: 1;
    padding: 30px 40px;
    overflow-y: auto;
    height: 100vh;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}
.greeting h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
}
.greeting p {
    margin: 5px 0 0;
    color: var(--text-muted);
}

/* --- Dashboard Widgets --- */
.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.widget-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: var(--glass-radius);
    padding: 25px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.inventory-widget {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(255, 255, 255, 0.6) 100%);
    border-left: 4px solid var(--danger-color);
}
.inventory-widget h3 {
    margin: 0 0 10px 0;
    color: var(--danger-hover);
    display: flex;
    align-items: center;
    gap: 10px;
}
.inventory-widget .low-stock-count {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--danger-color);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-icon-only {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    margin-right: 5px;
}

/* --- DataTables Overrides for Dribbble Look --- */
.table-section {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: var(--glass-radius);
    padding: 30px;
    box-shadow: var(--glass-shadow);
}

.table-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}
.table-header-flex h2 {
    margin: 0;
}

.filters-wrapper {
    display: flex;
    gap: 15px;
    align-items: center;
}

.form-select, .form-input {
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-family: inherit;
    font-size: 0.95rem;
    background: rgba(255,255,255,0.8);
    transition: all 0.2s;
    outline: none;
}
.form-select:focus, .form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 10px !important;
    width: 100% !important;
    border: none !important;
}

table.dataTable thead th {
    border: none !important;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    padding-bottom: 10px;
}

table.dataTable tbody tr {
    background: white !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    border-radius: 12px !important;
    transition: transform 0.2s;
}
table.dataTable tbody tr:hover {
    transform: scale(1.005);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

table.dataTable tbody td {
    border: none !important;
    padding: 15px 20px !important;
    vertical-align: middle;
}
table.dataTable tbody td:first-child { border-radius: 12px 0 0 12px; font-weight: 600; color: var(--text-main); }
table.dataTable tbody td:last-child { border-radius: 0 12px 12px 0; }

.badge-store {
    background: #e0e7ff;
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Low stock visual indicator */
table.dataTable tbody tr.low-stock-row td:first-child {
    position: relative;
}
table.dataTable tbody tr.low-stock-row td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 4px;
    background: var(--danger-color);
    border-radius: 0 4px 4px 0;
}

/* DataTables pagination */
.dataTables_wrapper .pagination {
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    gap: 5px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    border: none !important;
    background: white !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin: 0 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3) !important;
}

/* --- Forms & Modals --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #ffffff;
    margin: 5% auto;
    padding: 30px;
    width: 90%;
    max-width: 550px;
    border-radius: var(--glass-radius);
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}
.close-btn:hover { color: var(--danger-color); }

.modal h2 {
    margin-top: 0;
    margin-bottom: 25px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}
.form-element {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}
.form-element input, .form-element select, .form-element textarea {
    width: 100%;
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-family: inherit;
    background: #f8fafc;
    transition: all 0.2s;
}
.form-element input:focus, .form-element select:focus, .form-element textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Action buttons in tables */
.btn-action-icon {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 2px;
}
.btn-action-icon:hover.edit-btn { background: #e0e7ff; color: var(--primary-color); }
.btn-action-icon:hover.delete-btn { background: #fee2e2; color: var(--danger-color); }

/* --- Switch Toggle --- */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(22px); }
.switch-label { font-size: 0.9rem; font-weight: 500; margin-right: 10px; }

/* --- Manage Lists (Categories & Stores Modal) --- */
.manage-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}
.manage-list li {
    background: #f8fafc;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Mobile Responsiveness --- */
.mobile-nav-toggle {
    display: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
}

@media (min-width: 901px) {
    .sidebar-nav { display: flex !important; }
    .logout-wrapper { display: flex !important; }
}

@media (max-width: 900px) {
    .app-layout { flex-direction: column; }
    
    .sidebar {
        width: 100%;
        padding: 15px 20px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: var(--glass-border);
        position: sticky;
        top: 0;
        z-index: 50;
    }
    
    .sidebar-logo { margin-bottom: 0; order: 1; }
    .mobile-nav-toggle { display: block; order: 2; }
    
    .sidebar-nav, .logout-wrapper { 
        display: none; 
        flex: 1 1 100%;
        width: 100%;
        order: 3;
    }
    .sidebar-nav { margin-top: 15px; }
    
    .main-content { padding: 20px; }
    
    .form-grid { grid-template-columns: 1fr; }
    
    .table-header-flex { flex-direction: column; align-items: flex-start; }
    .filters-wrapper { width: 100%; flex-direction: column; align-items: flex-start; }
    .form-select { width: 100%; }
}

/* --- Meal Planner Additions --- */
.planner-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
}

.planner-sidebar {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: var(--glass-radius);
    padding: 25px;
    box-shadow: var(--glass-shadow);
}

.fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid { border: none !important; }
.fc-daygrid-day-frame { border: 1px solid #f1f5f9; border-radius: 10px; margin: 2px; }
.fc-day-today .fc-daygrid-day-frame { background: rgba(99, 102, 241, 0.05); border-color: rgba(99, 102, 241, 0.3); }

/* Alerts */
#alert-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }
.alert-container {
    padding: 15px 25px;
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    animation: slideLeft 0.3s ease;
    font-weight: 500;
}
@keyframes slideLeft {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--secondary-color); }
.alert-danger { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger-color); }

/* Utilities */
.text-danger { color: var(--danger-color); }
.text-success { color: var(--secondary-color); }

/* --- Auth Pages --- */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow: hidden;
    background: #f1f5f9;
}
/* Beautiful floating background blobs */
.auth-wrapper::before, .auth-wrapper::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(100px);
    z-index: 0;
    opacity: 0.6;
    animation: authBlobFloat 12s infinite ease-in-out alternate;
}
.auth-wrapper::before {
    background: linear-gradient(135deg, #a78bfa 0%, #c084fc 100%);
    top: -10%;
    left: -10%;
}
.auth-wrapper::after {
    background: linear-gradient(135deg, #60a5fa 0%, #34d399 100%);
    bottom: -10%;
    right: -10%;
    animation-delay: -6s;
}
@keyframes authBlobFloat {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.1); }
}

.auth-container {
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--glass-radius);
    padding: 40px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.05), inset 0 0 0 1px rgba(255,255,255,0.2);
    width: 100%;
    max-width: 450px;
    text-align: center;
    position: relative;
    z-index: 10;
}
.auth-logo {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}
.auth-container h2 { margin-top: 0; margin-bottom: 30px; font-weight: 700; }
.auth-container p { margin-top: 20px; color: var(--text-muted); }
.auth-container a { color: var(--primary-color); text-decoration: none; font-weight: 600; }
.auth-container a:hover { text-decoration: underline; }

.password-wrapper {
    position: relative;
    width: 100%;
    margin: 15px 0;
}
.password-toggle-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
}
.auth-container .password-wrapper input { 
    width: 100%;
    margin-bottom: 0;
    padding: 12px 40px 12px 15px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-family: inherit;
    background: #f8fafc;
    transition: all 0.2s; 
}
/* Hide native Edge/IE password reveal icon */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}
.password-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.auth-container input:not([type="checkbox"]) {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-family: inherit;
    background: #f8fafc;
    transition: all 0.2s;
}
.auth-container input:not([type="checkbox"]):last-of-type {
    margin-bottom: 0;
}
.auth-container input:focus:not([type="checkbox"]) {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}