/* =========================================
   1. GLOBAL RESET & VARIABLES
   ========================================= */
:root {
    --primary: #333367;
    --accent: #6366f1;
    --bg-color: #f1f5f9;
    --text-color: #1e293b;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* =========================================
   2. NAVBAR STYLES (Menu Middle, Logout End)
   ========================================= */
.navbar {
    background: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Flex Container */
.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    position: relative;
    height: 70px;
}

/* Logo Area */
.nav-title {
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
    flex-shrink: 0;
}

.nav-logo {
    max-width: 140px; 
    height: auto;
}

/* --- DESKTOP NAVIGATION (Min-Width 769px) --- */
@media screen and (min-width: 769px) {
    
    /* Center the menu links */
    .nav-links {
        display: flex;
        flex: 1;                 /* Takes up all remaining space */
        justify-content: center; /* Centers items in that space */
        align-items: center;
        gap: 30px;
        position: relative;
        height: 100%;
    }

    /* Lock Logout to the right using absolute position */
    .logout-btn {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .mobile-menu-btn {
        display: none !important; 
    }
}

.nav-link {
    font-weight: 600;
    color: #475569;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: #e2e8f0;
}

/* Logout Button Specifics */
.logout-btn {
    color: var(--danger) !important;
    border: 1px solid #fee2e2;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}
.logout-btn:hover {
    background: #fee2e2;
}

/* =========================================
   3. MOBILE STYLES (Max-Width 768px)
   ========================================= */
@media screen and (max-width: 768px) {
    
    .nav-content {
        justify-content: space-between;
    }

    .mobile-menu-btn {
        display: block !important;
        font-size: 24px;
        cursor: pointer;
        color: var(--primary);
        margin-left: 15px;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: white;
        flex-direction: column;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        border-top: 1px solid #f1f5f9;
        padding: 0;
        z-index: 999;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0;
        height: auto;
    }

    .nav-links.mobile-active {
        display: flex;
    }

    .nav-link {
        width: 100%;
        padding: 15px 20px;
        border-bottom: 1px solid #f1f5f9;
        text-align: left;
        border-radius: 0;
    }

    .logout-btn {
        position: static;
        transform: none;
        margin: 0;
        border: none;
        border-top: 1px solid #fee2e2;
        width: 100%;
        color: var(--danger);
        justify-content: flex-start;
    }
}

/* =========================================
   4. LAYOUT & CARDS
   ========================================= */
.container {
    max-width: 900px; /* Form Width */
    margin: 40px auto;
    padding: 0 20px;
}

.container.wide {
    max-width: 1200px; /* Table/Analysis Width */
}

.form-card {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.form-card h1 {
    font-size: 22px;
    color: var(--primary);
    margin-bottom: 5px;
}

.subtitle {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 25px;
}

/* =========================================
   5. FORMS & INPUTS
   ========================================= */
.form-group { margin-bottom: 20px; }
.row { display: flex; gap: 20px; margin-bottom: 20px; }
.col { flex: 1; }

label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"], input[type="password"], input[type="date"], input[type="tel"], select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    transition: border 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.submit-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

.submit-btn:hover { background: #282855; }

/* Radio/Checkbox Groups */
.option-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.option-item {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.option-input { margin-right: 8px; }

/* =========================================
   6. LOGIN PAGE FIXES
   ========================================= */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f1f5f9;
}

.login-wrapper { width: 100%; max-width: 400px; padding: 20px; }
.login-logo { max-width: 180px; height: auto; margin: 0 auto; display: block; }

.password-wrapper { position: relative; width: 100%; }
.password-wrapper input { width: 100%; padding-right: 40px; }
.toggle-password { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #94a3b8; z-index: 10; }

/* =========================================
   7. TABLE STYLES (Fixed Alignment)
   ========================================= */
.table-card { padding: 0; overflow: hidden; }

.table-header-area {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
}

.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

/* Header Cells */
th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    text-align: left;
    padding: 12px 15px;
    white-space: nowrap; /* Keeps headers on one line */
    border-bottom: 2px solid #e2e8f0;
    vertical-align: middle;
}

/* Data Cells - The Fix for broken layout */
td {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle; /* Centers text vertically */
    white-space: nowrap;    /* Prevents wrapping, forcing horizontal scroll if needed */
}

/* Hover effect */
tr:hover { background-color: #f8fafc; }

/* Action Icons */
.action-cell {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-start;
}

.btn-edit, .btn-delete {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 15px;
    padding: 4px;
}
.btn-edit { color: var(--accent); }
.btn-delete { color: var(--danger); }

/* =========================================
   8. ANALYSIS DASHBOARD
   ========================================= */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.metric-info h4 { font-size: 12px; text-transform: uppercase; color: #64748b; margin-bottom: 5px; }
.metric-info h2 { font-size: 24px; color: #1e293b; font-weight: 700; margin: 0; }
.metric-icon { width: 45px; height: 45px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; }

.m-blue .metric-icon { background: #dbeafe; color: #2563eb; }
.m-green .metric-icon { background: #d1fae5; color: #059669; }
.m-purple .metric-icon { background: #ede9fe; color: #7c3aed; }
.m-orange .metric-icon { background: #ffedd5; color: #ea580c; }

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.card-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 20px;
    padding-bottom: 10px; border-bottom: 1px solid #f1f5f9;
}
.card-header i { color: var(--accent); }
.card-header h3 { font-size: 15px; color: #333; margin: 0; }
.chart-wrapper { height: 250px; position: relative; }

.coordinator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}
.coord-card {
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.coord-name { font-weight: 600; font-size: 13px; }
.coord-count { background: #333367; color: white; padding: 2px 8px; border-radius: 10px; font-size: 12px; }

@media screen and (max-width: 600px) {
    .row { flex-direction: column; gap: 10px; }
    .login-wrapper { padding: 15px; }
}