/* public/assets/style.css */

@media (max-width: 1024px) {
    .wrapper {
        display: block !important; /* Stack sidebar and content */
    }
    
    .sidebar {
        /* Ensure sidebar is hidden by default on mobile/tablet */
        /* and only shows when the toggle button is clicked */
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        z-index: 9999;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
}


/* --- Tablet & Mobile Layout Fixes --- */

/* Fix for tablet sidebar overlapping or squishing content */
@media (max-width: 1024px) {
    .mobile-header {
        display: flex !important; /* Ensure header shows on tablets */
        align-items: center;
        gap: 15px;
        padding: 10px 20px;
        background: white;
        border-bottom: 1px solid #eee;
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .mobile-spacing-container {
        padding: 15px !important;
        margin-top: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    .table-responsive {
        border: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling for iPad */
    }
}

/* Base Modal Container (Allows vertical scrolling) */
#updateModal, #signatoryModal {
    overflow-y: auto;
    display: none; /* Controlled by JS */
    padding: 20px 0;
}


/* --- 1. THEME VARIABLES (Management Center) --- */
:root {
    /* Brand Colors */
    --primary: #4f46e5;       /* Indigo 600 */
    --primary-hover: #4338ca; /* Indigo 700 */
    --primary-light: #e0e7ff; /* Indigo 100 */
    
    /* Functional Colors */
    --success-bg: #d1fae5; --success-text: #065f46; /* Green */
    --warning-bg: #fef3c7; --warning-text: #92400e; /* Amber */
    --danger-bg: #fee2e2;  --danger-text: #b91c1c;  /* Red */
    
    /* Neutrals */
    --bg-body: #f1f5f9;       /* Slate 100 */
    --bg-card: #ffffff;
    --text-main: #0f172a;     /* Slate 900 */
    --text-muted: #64748b;    /* Slate 500 */
    --border: #e2e8f0;        /* Slate 200 */

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;        /* 12px rounded corners */
    --font-main: 'Plus Jakarta Sans', sans-serif;
}

/* --- 2. RESET & BASE --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    font-family: var(--font-main);
    font-size: 0.925rem;
    height: 100vh;
    display: flex;
    overflow: hidden; /* Prevent body scroll, let content scroll */
}
a { text-decoration: none; color: inherit; }

/* --- 3. LAYOUT (Sidebar & Main) --- */
.wrapper { display: flex; width: 100%; height: 100%; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: margin-left 0.3s ease;
    z-index: 50;
    flex-shrink: 0;
}
.sidebar-header {
    font-size: 1.25rem; font-weight: 800; color: var(--primary);
    display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2.5rem;
}
.main-content {
    flex: 1;
    overflow-y: auto; /* Scrollable area */
    padding: 2rem;
    position: relative;
}

/* Mobile Sidebar Toggle & Header */
@media (max-width: 768px) {
    .sidebar { position: fixed; height: 100%; left: -260px; transition: left 0.3s; }
    .sidebar.open { left: 0; box-shadow: var(--shadow-md); }
    .main-content { padding: 1rem; }

    /* The Mobile Header Fix */
    .mobile-header { 
        display: flex !important; 
        align-items: center; 
        justify-content: space-between; 
        padding: 1rem; 
        background: white; 
        border-bottom: 1px solid var(--border); 
        position: fixed; 
        top: 0; left: 0; right: 0; 
        z-index: 40; 
    }
    .wrapper { 
        margin-top: 60px; /* Push content down for mobile header */ 
    }
    /* Fix Grid collapsing on mobile */
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* --- 4. COMPONENTS --- */

/* Navigation Links */
.nav-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem; justify-content: center;
    padding: 0.625rem 1.25rem;
    font-weight: 600; font-size: 0.875rem;
    border-radius: 0.5rem; border: 1px solid transparent;
    cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: white; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-body); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.75rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; color: #009C05; }
.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: border 0.2s, box-shadow 0.2s;
    background: #fff;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Tables */
.table-responsive { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: white; font-size: 0.9rem; }
th { text-align: left; padding: 1rem; background: var(--bg-body); color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
td { padding: 1rem; border-top: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
tr:hover td { background: #f8fafc; }

/* Status Badges */
.badge { padding: 0.25rem 0.75rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger  { background: var(--danger-bg); color: var(--danger-text); }

/* --- 5. UTILITIES --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }

/* Suggestions Box (for TA Needs search) */
.suggestions-box {
    position: absolute; width: 100%; background: white; border: 1px solid var(--border);
    border-radius: 0.5rem; max-height: 200px; overflow-y: auto; z-index: 100;
    box-shadow: var(--shadow-md); margin-top: 4px;
}
.suggestion-item { padding: 0.75rem; cursor: pointer; font-size: 0.9rem; border-bottom: 1px solid var(--bg-body); }
.suggestion-item:hover { background: var(--primary-light); color: var(--primary); }

/* --- 6. MODAL SYSTEM FIX --- */
#updateModal {
    display: none; /* Controlled by JS */
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7); /* Dark semi-transparent slate */
    z-index: 9999; /* Ensure it is above everything else */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 1rem;
}

#updateModal:not(.hidden) {
    display: flex !important;
}

/* Ensure the card inside doesn't shrink too much */
#updateModal .card {
    width: 100%;
    max-width: 650px;
    margin: auto;
    max-height: 90vh;
    overflow-y: auto;
    position: relative; /* Prevents click-through issues */
}

/* Styling for the modal specific layout */
#updateModal .grid-2 {
    margin-bottom: 1rem;
}

#updateModal .form-group textarea {
    resize: vertical; /* Let users expand the box if they have a lot to say */
    min-height: 80px;
}

/* Make the Cancel button look slightly distinct from the primary action */
.btn-outline {
    border: 1px solid var(--border);
    background-color: transparent;
}

.btn-outline:hover {
    background-color: #f8fafc;
    border-color: var(--text-muted);
}

.ta-needs-text {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}

#updateModal p#ref_needs {
    background: rgba(255, 255, 255, 0.5);
    padding: 0.75rem;
    border-radius: 0.35rem;
    border: 1px dashed var(--border);
    white-space: pre-wrap; /* Preserves line breaks from the database */
}

.table-responsive {
    width: 100%;
    overflow-x: auto; /* Allows horizontal scrolling */
    -webkit-overflow-scrolling: touch;
}

table {
    min-width: 1200px; /* Ensures columns have enough room to spread out */
}

td {
    vertical-align: top; /* Better for reading rows with varying text lengths */
}

/* Style for the mini-remarks box in the table */
td div[style*="border-left"] {
    box-shadow: var(--shadow-sm);
    line-height: 1.4;
    word-break: break-word;
}

/* Ensure the action buttons don't stretch */
.btn-sm {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

table td {
    padding: 1rem 0.75rem;
    vertical-align: middle; /* Kept middle for a cleaner horizontal look */
}


/* public/assets/style.css */

/* --- 1. DESIGN TOKENS --- */
:root {
    /* Brand & Primary */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #f5f3ff;
    
    /* Semantic Status */
    --success: #059669; --success-bg: #ecfdf5;
    --warning: #d97706; --warning-bg: #fffbeb;
    --danger: #dc2626;  --danger-bg: #fef2f2;
    
    /* Neutral Palette */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-500: #64748b;
    --slate-900: #0f172a;

    /* Surface & Borders */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --border: var(--slate-200);
    
    /* Typography */
    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    
    /* Shadows & Rounding */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius-md: 0.5rem;
    --radius-lg: 0.85rem;
}

/* --- 2. BASE RESET --- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-body);
    color: var(--slate-900);
    font-family: var(--font-main);
    font-size: 0.9375rem;
    line-height: 1.5;
    /* FIX: Changed height to min-height and removed overflow: hidden from body */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- 3. CORE LAYOUT --- */
.wrapper { 
    display: flex; 
    width: 100%; 
    flex: 1; /* Allows wrapper to grow to fill screen */
    position: relative; 
}

.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.25rem;
    flex-shrink: 0;
    z-index: 100;
    /* Keeps sidebar fixed on the side during scroll */
    position: sticky;
    top: 0;
    height: 100vh;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content {
    flex: 1;
    /* Removed overflow-y: auto from here to let the BODY handle the main scroll */
    padding: 2.5rem;
    min-width: 0; /* Prevents flex items from breaking layout */
}

/* --- MOBILE & TABLET OPTIMIZATIONS --- */
@media (max-width: 1024px) {
    body {
        overflow-y: auto; /* Ensure scrolling is enabled */
    }

    .sidebar { 
        position: fixed; 
        inset-block: 0;
        left: 0;
        transform: translateX(-100%); 
        height: 100%;
    }
    
    .sidebar.open { 
        transform: translateX(0); 
        box-shadow: var(--shadow-md); 
    }
    
    .mobile-header {
        display: flex !important;
        position: sticky; /* Sticky is better for scrolling content */
        top: 0;
        height: 64px;
        background: white;
        border-bottom: 1px solid var(--border);
        padding-inline: 1.25rem;
        align-items: center;
        justify-content: space-between;
        z-index: 1000;
    }

    .main-content { 
        padding: 1.5rem 1rem; 
        width: 100%;
    }

    .grid-2, .grid-3 { 
        grid-template-columns: 1fr; 
    }
}

/* --- 4. UI COMPONENTS --- */

/* Navigation */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    color: var(--slate-500);
    border-radius: var(--radius-md);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.nav-link:hover, .nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* Data Display */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-outline { background: white; border-color: var(--border); color: var(--slate-900); }
.btn-outline:hover { background: var(--slate-50); border-color: var(--slate-500); }

/* --- 5. DATA TABLES --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    min-width: 1000px; /* Adjusted from 1200 for better tablet fit */
    border-collapse: collapse;
    background: white;
}

th {
    background: var(--slate-50);
    color: var(--slate-500);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem;
    text-align: left;
}

td {
    padding: 1rem;
    border-top: 1px solid var(--border);
    vertical-align: top;
}

.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }

/* --- 6. MODAL & OVERLAYS --- */
#updateModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    padding: 1.5rem;
    align-items: center;
    justify-content: center;
}

#updateModal:not(.hidden) { display: flex !important; }

#updateModal .card {
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 7. UTILITIES --- */
.grid-stack { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.hidden { display: none !important; }

/* Truncation with Tooltip hint */
.truncate-text {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}