@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    /* Matte / Pastel Colors */
    --default-ops: #10B981; /* Matte Emerald Green Default */
    --blue-ops: #3B82F6;    /* Matte Blue */
    --red-ops: #EF4444;     /* Matte Red */
    --green-ops: #10B981;   /* Matte Emerald Green */
    --orange-ops: #F59E0B;  /* Matte Amber */
    
    /* Softened Text */
    --text-white: #E2E8F0;  /* Off-white to prevent glare */
    --text-gray: #94A3B8;
    --text-dark: #0F172A;   /* Slate dark instead of pitch black */
    
    /* Theme Defaults */
    --theme-primary: var(--default-ops);
    
    /* Flat & Calmed Backgrounds */
    --bg-body: #0F172A;
    --bg-sidebar: #1E293B;
    --bg-cell: #1E293B;       
    --bg-surface: #334155;
    --border-color: #475569;
    
    --radius-main: 12px;
    --radius-pill: 50px;
    --sidebar-width: 280px;
}

/* --- DYNAMIC BACKGROUND & ACCENT SHIFTS --- */
body.theme-admin { --theme-primary: var(--blue-ops); }
body.theme-ops { --theme-primary: var(--red-ops); }
body.theme-res { --theme-primary: var(--green-ops); }
body.theme-oth { --theme-primary: var(--orange-ops); }

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

h1, h2, h3, h4, .cal-month, .cal-year, .day-header, .btn-new-activity, .cal-subtitle, .cell-num {
    font-family: 'Poppins', sans-serif;
}

/* SMOOTH TRANSITIONS */
body, .sidebar, .cal-cell, .input-box, .modal-content, .dash-container, .dash-card, .search-pill, .side-drawer, .nav-item.active {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-body);
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 40px 40px; 
    background-position: center center;
    color: var(--text-white);
    display: flex;
    height: 100vh;
    overflow: hidden; 
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-gray); }

/* Loading & Mobile */
#loadingOverlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.95); z-index: 3000;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.spinner {
    width: 50px; height: 50px; border: 4px solid var(--bg-surface);
    border-top: 4px solid var(--theme-primary); border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.mobile-menu-btn {
    display: none; position: absolute; top: 15px; left: 15px; z-index: 1500;
    background: var(--bg-surface); border: 1px solid var(--border-color); color: var(--text-white);
    padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 1.5rem;
}
#mobileOverlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-body); opacity: 0.8; z-index: 1400; backdrop-filter: blur(4px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width); background-color: var(--bg-sidebar);
    display: flex; flex-direction: column; border-right: 1px solid var(--border-color);
    flex-shrink: 0; z-index: 1500; padding: 20px; gap: 25px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1); 
    position: relative; 
}
.sidebar-logo { width: 100%; display: flex; justify-content: center; align-items: center; padding-top: 2px; }
.sidebar-logo img { max-width: 90px; height: auto; display: block; opacity: 0.9; }

.sidebar-header { flex-shrink: 0; }
.search-pill {
    background-color: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-main); padding: 10px 15px; display: flex;
    align-items: center; justify-content: space-between; color: var(--text-white);
}
.search-pill:focus-within { border-color: var(--theme-primary); }
.search-left { display: flex; align-items: center; gap: 10px; flex-grow: 1; }
.search-left input { background: transparent; border: none; color: var(--text-white); outline: none; width: 100%; font-size: 0.9rem; }
.search-time { font-size: 0.75rem; color: var(--text-gray); font-weight: 500; white-space: nowrap; margin-left: 5px;}

/* Add Button */
.btn-new-activity {
    width: 100%; padding: 12px; background: var(--theme-primary); color: var(--text-white);
    border: none; border-radius: var(--radius-main); font-weight: 600; font-size: 0.9rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: background-color 0.2s, transform 0.1s;
}
.btn-new-activity:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-new-activity.locked { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); transform: none; background: var(--bg-surface); color: var(--text-gray); }

.nav-group { display: flex; flex-direction: column; gap: 5px; }
.nav-label { font-size: 0.7rem; color: var(--text-gray); font-weight: 600; letter-spacing: 1px; margin-bottom: 5px; padding-left: 10px; text-transform: uppercase; }

/* Navigation Items */
.nav-item {
    background: transparent; border: none; color: var(--text-gray); width: 100%; text-align: left;
    padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 500;
    display: flex; align-items: center; gap: 12px; transition: all 0.15s ease-out;
}
.nav-item:hover { 
    background-color: var(--bg-surface); 
    color: var(--text-white);
}
.nav-item.active { 
    background: var(--bg-surface); 
    color: var(--text-white); 
    font-weight: 500; 
    border-left: 3px solid var(--active-color, var(--text-white)); 
}

#btnNavCal { display: none; }
.section-dot { width: 8px; height: 8px; border-radius: 50%; background-color: var(--dot-color); } 

.recent-section { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; border-top: 1px solid var(--border-color); padding-top: 20px; }
.recent-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding: 0 5px; }
.recent-header h4 { font-size: 0.8rem; color: var(--text-gray); font-weight: 600; text-transform: uppercase; }
.recent-header button { background: none; border: none; color: var(--theme-primary); font-size: 0.75rem; cursor: pointer; font-weight: 500; }
.mini-list { overflow-y: auto; padding-right: 5px; display: flex; flex-direction: column; gap: 8px; }
.mini-item {
    padding: 10px; border-radius: 8px; background: var(--bg-cell);
    border: 1px solid var(--border-color); cursor: pointer; transition: 0.2s;
}
.mini-item:hover { background: var(--bg-surface); border-color: var(--text-gray); }
.mini-title { font-size: 0.85rem; color: var(--text-white); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400;}
.mini-meta { font-size: 0.7rem; color: var(--text-gray); display: flex; justify-content: space-between; }

/* Main Content */
.main-content { flex-grow: 1; padding: 30px; display: flex; flex-direction: column; position: relative; overflow: hidden; z-index: 1; }
.cal-header { margin-bottom: 20px; flex-shrink: 0; }
.cal-month { font-size: 1.5rem; font-weight: 400; color: var(--text-white); }
.cal-year-wrapper { display: flex; align-items: center; gap: 15px; }
.cal-year { font-size: 2.5rem; font-weight: 600; line-height: 1; color: var(--text-white); } 

.btn-lock {
    background: transparent; border: 2px solid var(--border-color); color: var(--text-gray);
    width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center;
    cursor: pointer; font-size: 1.2rem; transition: 0.2s;
}
.btn-lock.unlocked { border-color: var(--green-ops); color: var(--green-ops); }
.btn-lock:hover { background: var(--bg-surface); }
.cal-subtitle { font-size: 0.85rem; font-weight: 500; letter-spacing: 1px; color: var(--text-gray); margin-top: 5px; text-transform: uppercase;}

.controls { position: absolute; top: 30px; right: 30px; display: flex; gap: 10px; z-index: 10;}
.controls select { background: var(--bg-surface); color: var(--text-white); border: 1px solid var(--border-color); padding: 5px 10px; border-radius: 5px; cursor: pointer; outline: none;}
.controls select:focus { border-color: var(--theme-primary); }

/* Calendar */
.calendar-wrapper { 
    width: 100%; flex-grow: 1; overflow: auto; -webkit-overflow-scrolling: touch; 
    position: relative; border-radius: 10px;
}
.calendar-grid {
    display: grid; 
    grid-template-columns: repeat(7, 1fr);
    /* grid-template-rows is dynamically set in app.js */
    gap: 15px; 
    margin-bottom: 30px; 
    min-width: 800px; 
    padding: 5px; 
    position: relative;
}
.day-header { text-align: center; color: var(--text-gray); font-weight: 500; font-size: 0.85rem; text-transform: uppercase; padding: 15px; border-radius: 8px; }
.day-header.weekend { color: var(--red-ops); }
.day-header.active { background-color: var(--bg-surface); color: var(--theme-primary); border: 1px solid var(--border-color); }

.cal-cell {
    background-color: var(--bg-cell); border: 1px solid var(--border-color); border-radius: 8px; 
    padding: 12px; position: relative; cursor: pointer; display: flex; flex-direction: column; overflow: hidden;
}
.cal-cell.weekend-cell { background-color: rgba(239, 68, 68, 0.03); }
.cal-cell:hover { background-color: var(--bg-surface); border-color: var(--text-gray); }
.cell-num { font-size: 1rem; color: var(--text-gray); font-weight: 400; margin-bottom: 8px; }

.is-today .cell-num { color: var(--theme-primary); font-weight: 600; }
.is-today { border: 2px solid var(--theme-primary); background-color: rgba(16, 185, 129, 0.05); }

.cal-cell.empty-cell {
    background: transparent;
    border-color: transparent;
    pointer-events: none;
}

/* --- DRAWER SYSTEM --- */
.drawer-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5); 
    z-index: 2400; visibility: hidden; transition: all 0.2s ease; opacity: 0;
}
.drawer-overlay.active { opacity: 1; visibility: visible; }
.side-drawer {
    position: fixed; top: 0; right: -450px; width: 420px; max-width: 100%; height: 100vh;
    background-color: var(--bg-sidebar); border-left: 1px solid var(--border-color); 
    z-index: 2500; padding: 30px; overflow-y: auto; 
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
}
.side-drawer.active { right: 0; }
.drawer-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; flex-shrink: 0;
}
.close-drawer { background: transparent; border: none; color: var(--text-gray); font-size: 1.5rem; cursor: pointer; }
.close-drawer:hover { color: var(--text-white); }

/* Forms & Inputs */
.input-box { background-color: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-main); padding: 12px; margin-bottom: 15px; }
.input-box:focus-within { border-color: var(--theme-primary); }
.input-box label { display: block; font-size: 0.7rem; color: var(--text-gray); font-weight: 500; margin-bottom: 5px; text-transform: uppercase;}
.input-box input, .input-box textarea, .input-box select { width: 100%; border: none; outline: none; font-size: 0.95rem; color: var(--text-white); background: transparent; }
.input-box textarea { resize: vertical; }
.date-group { display: flex; gap: 10px; flex-wrap: wrap;}
.input-half { flex: 1; min-width: 120px; }
.modal-section-pill { display: inline-block; padding: 8px 20px; border-radius: 50px; font-weight: 500; color: var(--bg-body); margin-bottom: 20px; min-width: 150px; text-align: center; background: var(--text-white);}

.btn-done { background-color: var(--theme-primary); color: var(--text-white); border: none; width: 100%; padding: 12px; border-radius: 50px; font-weight: 500; font-size: 0.95rem; cursor: pointer; margin-top: 10px; transition: 0.2s;}
.btn-done:disabled { background-color: var(--bg-surface); color: var(--text-gray); cursor: not-allowed; }
.btn-done:not(:disabled):hover { filter: brightness(1.1); }

/* Modals */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(15, 23, 42, 0.7); justify-content: center; align-items: center; }
.modal-content { background-color: var(--bg-sidebar); border: 1px solid var(--border-color); padding: 30px; border-radius: 12px; width: 450px; position: relative; max-height: 90vh; overflow-y: auto; max-width: 90%; }
.close-modal { position: absolute; top: 15px; right: 20px; color: var(--text-gray); font-size: 1.5rem; cursor: pointer; }
.close-modal:hover { color: var(--text-white); }

/* Tables & Lists */
table { width: 100%; border-collapse: collapse; color: var(--text-white); }
th { text-align: left; color: var(--text-gray); padding: 10px; border-bottom: 1px solid var(--border-color); font-weight: 500; font-size: 0.85rem; text-transform: uppercase; }
td { padding: 12px 10px; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; vertical-align: middle; }
.list-modal-content { width: 850px; max-width: 95%; }
.list-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 15px;}
.search-container-list { position: relative; }
.search-icon-list { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-gray); font-size: 0.8rem; }
#listSearchInput { padding: 8px 15px 8px 35px; border-radius: 20px; border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-white); outline: none; font-size: 0.9rem; width: 250px; transition: border-color 0.2s;}
#listSearchInput:focus { border-color: var(--theme-primary); }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; padding-bottom: 5px; align-items: center; }
.filter-pill { background: transparent; border: 1px solid var(--border-color); color: var(--text-gray); padding: 6px 15px; border-radius: 20px; cursor: pointer; font-size: 0.8rem; font-weight: 400; transition: 0.2s;}
.filter-pill:hover { border-color: var(--text-white); color: var(--text-white); }
.filter-pill.active { background: var(--text-white); color: var(--text-dark); border-color: var(--text-white); }
.filter-divider { width: 1px; height: 20px; background: var(--border-color); margin: 0 5px; }

.total-count-badge { background: transparent; color: var(--text-gray); padding: 6px 15px; border-radius: 20px; font-size: 0.85rem; font-weight: 500; border: 1px solid var(--border-color); }
.total-count-badge.filtered { color: var(--theme-primary); border-color: var(--theme-primary); }

.status-badge { padding: 5px 12px; border-radius: 15px; font-size: 0.75rem; font-weight: 500; text-transform: uppercase; cursor: pointer; display: inline-block; border: 1px solid transparent; }
.status-badge.pending { background: rgba(239, 68, 68, 0.1); color: var(--red-ops); border-color: var(--red-ops); }
.status-badge.done { background: rgba(16, 185, 129, 0.1); color: var(--green-ops); border-color: var(--green-ops); }
.status-badge.disabled { opacity: 0.6; cursor: not-allowed; }

/* Dashboard Cards */
.dash-container { width: 80%; max-width: 800px; background: var(--bg-sidebar); padding: 40px; border-radius: 12px; border: 1px solid var(--border-color); position: relative; }
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 20px;}
.dash-card { background: var(--bg-surface); padding: 25px; border-radius: 8px; border: 1px solid var(--border-color); display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.dash-value { font-size: 2.5rem; font-weight: 500; color: var(--text-white); margin: 10px 0; }
.dash-label { color: var(--text-gray); text-transform: uppercase; font-size: 0.8rem; font-weight: 500; letter-spacing: 1px; }
.progress-wrapper { background: var(--bg-sidebar); height: 8px; border-radius: 4px; width: 100%; overflow: hidden; margin-top: 10px; border: 1px solid var(--border-color); }
.progress-fill { height: 100%; background: var(--theme-primary); width: 0%; transition: width 0.5s ease; }

/* Files & Gallery */
.doc-btn { padding: 5px 10px; font-size: 0.8rem; border-radius: 6px; cursor: pointer; border: none; font-weight: 400; margin-right: 5px; color: var(--text-white); transition: 0.2s;}
.btn-upload { background: var(--bg-surface); border: 1px solid var(--border-color); }
.btn-upload:hover { border-color: var(--text-gray); }
.btn-pdf { background: var(--bg-surface); border: 1px solid var(--border-color); }
.btn-pdf:hover { border-color: var(--text-gray); }
.btn-link { background: var(--bg-surface); border: 1px solid var(--border-color); }
.btn-link:hover { border-color: var(--text-gray); }
.btn-view-docs { background: var(--border-color); color: var(--text-white); }
.btn-view-docs:hover { background: var(--theme-primary); }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; margin-top: 15px; }
.gallery-item { width: 100%; aspect-ratio: 1; border-radius: 4px; overflow: hidden; position: relative; border: 1px solid var(--border-color); cursor: zoom-in; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.gallery-item:hover img { transform: scale(1.05); }
.gallery-empty { text-align: center; color: var(--text-gray); font-style: italic; margin-top: 20px; }
.btn-delete-photo { position: absolute; top: 5px; right: 5px; background: rgba(239, 68, 68, 0.9); color: white; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-weight: bold; z-index: 10; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; }

.pdf-section-title { margin-top: 25px; margin-bottom: 10px; font-size: 0.9rem; color: var(--text-gray); font-weight: 500; border-top: 1px solid var(--border-color); padding-top: 10px;}
.pdf-list { display: flex; flex-direction: column; gap: 8px; }
.pdf-card { background: var(--bg-surface); padding: 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border-color); }
.pdf-info { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--text-white); overflow: hidden; }
.pdf-icon { color: var(--text-gray); font-size: 1.2rem; flex-shrink: 0;}
.pdf-actions { display: flex; gap: 5px; flex-shrink: 0;}
.btn-pdf-action { padding: 4px 10px; border-radius: 4px; border:none; cursor: pointer; font-size: 0.75rem; font-weight: 500; transition: 0.2s; }
.btn-download-pdf { background: var(--bg-body); color: var(--text-white); border: 1px solid var(--border-color); }
.btn-download-pdf:hover { border-color: var(--text-gray); }
.btn-delete-pdf { background: transparent; color: var(--red-ops); border: 1px solid var(--border-color);}

.lightbox-content { display: flex; flex-direction: column; align-items: center; width: 100%; height: 100%; justify-content: center; }
.lightbox-img-wrapper { max-width: 100%; max-height: 80vh; overflow: hidden; border-radius: 8px; border: 1px solid var(--border-color); }
.lightbox-img-wrapper img { max-width: 100%; max-height: 80vh; object-fit: contain; display: block; }
.btn-download-main { background-color: var(--theme-primary); color: var(--text-white); padding: 10px 20px; border-radius: 30px; border: none; font-weight: 500; margin-top: 15px; cursor: pointer; }
.btn-download-all { background-color: var(--bg-surface); color: var(--text-white); border: 1px solid var(--border-color); padding: 8px 15px; border-radius: 20px; font-weight: 400; font-size: 0.8rem; cursor: pointer; float: right; transition: 0.2s;}
.btn-download-all:hover { border-color: var(--text-gray); }

.btn-icon { background: none; border: none; color: var(--text-gray); cursor: pointer; font-size: 1.2rem; transition: 0.2s;}
.btn-icon:hover { color: var(--text-white); }

.notification { position: fixed; bottom: 30px; right: 30px; background: var(--theme-primary); color: var(--text-white); padding: 15px 25px; border-radius: 8px; font-weight: 500; display: none; z-index: 3500; }
.signature-watermark { position: absolute; bottom: 5px; right: 10px; font-size: 0.65rem; color: rgba(226, 232, 240, 0.1); font-weight: 300; pointer-events: none; z-index: 0; }

/* Responsive */
@media (max-width: 900px) {
    .mobile-menu-btn { display: block; }
    .sidebar { position: fixed; top: 0; left: 0; height: 100%; transform: translateX(-100%); z-index: 2000; }
    .sidebar.active { transform: translateX(0); }
    #btnNavCal { display: flex; }
    .main-content { padding: 15px; padding-top: 60px; }
    .controls { top: 15px; right: 15px; }
    
    .calendar-grid { 
        gap: 10px; 
        min-width: 750px; 
        padding-bottom: 15px;
    }
    .calendar-wrapper { 
        max-height: 70vh; 
        display: block; 
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch;
        padding-bottom: 10px;
    }
    .day-header { padding: 10px; font-size: 0.8rem; }
    .cal-cell { padding: 5px; }
    .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .cal-header { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; margin-bottom: 15px; }
    .cal-year-wrapper { order: -1; } 
    .controls { position: relative; top: 0; right: 0; margin-bottom: 15px; width: 100%; display: flex; justify-content: space-between;}
    .controls select { flex-grow: 1; }
    .side-drawer { width: 100%; right: -100%; }
    .modal-content { padding: 20px; }
    th, td { padding: 8px; font-size: 0.8rem; }
}

/* --- GANTT CHART STYLES --- */
.gantt-event {
    position: relative;
    z-index: 5;
    height: 24px;
    border-radius: 6px;
    color: #fff;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    padding: 0 8px;
    margin: 0 4px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    align-self: start;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.1s, filter 0.1s;
}
.gantt-event:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    z-index: 10;
}
.gantt-title {
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    pointer-events: none;
    width: 100%;
}