/* Dashboard Core Variables - Mapped to Global Theme */
:root {
    --bg-dark: var(--bg-main);
    --card-bg: var(--bg-card);
    --text-primary: var(--text-main);
    --text-secondary: var(--text-muted);
    --sierra-blue: #3498db;
    --sierra-red: var(--danger);
    /* For AOC & Alerts */
    --sierra-gold: var(--warning);
    --success-green: var(--accent);

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    --nav-height: 60px;
    --aoc-height: 40px;
}

body.dashboard-body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow-x: hidden;
}

/* Global Header Navigation - styles owned by style.css */


.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* 2. AOC Banner */
.aoc-banner {
    height: var(--aoc-height);
    background: var(--sierra-red);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 100;
    color: #fff;
}

.aoc-label {
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.aoc-value {
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
}

.aoc-status {
    width: 10px;
    height: 10px;
    background: #00e676;
    /* Bright Green LED */
    border-radius: 50%;
    box-shadow: 0 0 8px #00e676;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Main Grid - Desktop Layout (> 1024px) */
.dashboard-grid {
    display: grid;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    /* Default: 2 columns if no dynamic right cards are visible */
    grid-template-columns: 350px 1fr;
    grid-auto-flow: row dense;
    align-items: start;
    box-sizing: border-box;
}

/* 3-column layout when right sidebar is active */
.dashboard-grid.has-right-col {
    grid-template-columns: 350px 1fr 350px;
}

.desktop-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Roster spans all columns, inside the main grid now */
#roster-card {
    grid-column: 1 / -1;
    margin-top: 20px;
}

/* Collapsible States */
.card-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 10px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.card.collapsed .card-toggle {
    transform: rotate(-90deg);
}

.card.collapsed .card-body,
.card.collapsed .card-footer {
    display: none !important;
}

.card-header.clickable {
    cursor: pointer;
    user-select: none;
}


/* Roster Section */
/* Align Roster with Center Column (300px side + 20px gap + 20px grid padding = 340px from edge) */
.roster-section-container {
    padding: 0 20px 40px 20px;
    max-width: 1540px;
    margin: 0 auto;
    display: block;
}

/* Roster Card itself takes full available width of the container */
.roster-section-container .roster-card {
    width: 100%;
    max-width: none;
}

.roster-list-columns {
    column-count: 4;
    column-gap: 20px;
    padding: 15px;
}

.r-item {
    break-inside: avoid;
    background: var(--bg-input);
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.r-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.r-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.r-contact {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 120px;
}

/* Fix Memos Height */
.memo-list {
    min-height: 350px;
    max-height: 600px;
    overflow-y: auto;
}

@media (max-width: 1200px) {
    .roster-list-columns {
        column-count: 3;
    }
}

@media (max-width: 900px) {
    .roster-list-columns {
        column-count: 2;
    }
}

@media (max-width: 600px) {
    .roster-list-columns {
        column-count: 1;
    }
}

.grid-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header {
    background: var(--bg-card);
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left !important;
    justify-content: flex-start;
    flex: 1;
}

#lineup-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.light-mode #lineup-date {
    color: #333;
}

.card-body {
    padding: 15px;
    overflow-y: auto;
    font-size: 1.1rem;
}

/* Profile Specific */
.radio-badge {
    background: var(--bg-input);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
    color: var(--sierra-gold);
    border: 1px solid var(--border);
}

/* Unit Grid (Tactical Lineup) */
.unit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.unit-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    color: var(--text-primary);
}

.unit-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
}

.slot-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.slot-row:last-child {
    border-bottom: none;
}

.slot-role {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Tabs */
.tab-header {
    padding: 0;
    display: flex;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px;
    cursor: pointer;
    font-weight: 600;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--sierra-blue);
    background: var(--bg-card);
}

.tab-btn.restricted.active {
    border-bottom-color: var(--sierra-red);
}

/* Modal */


.hidden {
    display: none !important;
}

.alert-modal {
    background: #1e1e1e;
    border: 2px solid var(--sierra-red);
    border-radius: 12px;
    width: 600px;
    max-width: 90vw;
    box-shadow: 0 0 30px rgba(198, 40, 40, 0.3);
}

.alert-header {
    background: var(--sierra-red);
    padding: 15px;
    text-align: center;
}

.alert-header h2 {
    margin: 0;
    color: white;
    font-size: 1.2rem;
}

.alert-body {
    padding: 30px;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
}

.alert-footer {
    padding: 20px;
    display: flex;
    justify-content: center;
}

.ack-btn {
    background: var(--sierra-red);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.3s;
}

.ack-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #555;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #121212;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

/* Profile Modal Styles */
.profile-modal {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.modal-header {
    background: var(--bg-header);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-inverse);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-inverse);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.close-btn:hover {
    color: var(--sierra-red);
    transform: scale(1.1);
}

.close-btn:hover {
    color: var(--sierra-red);
}

.modal-body {
    padding: 20px;
    background: var(--bg-main);
    max-height: 70vh;
    overflow-y: auto;
}

/* Profile Tabs */
.profile-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.profile-tabs button {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-weight: 500;
}

.profile-tabs button.active,
.profile-tabs button:hover {
    color: var(--text-main);
    border-bottom-color: var(--sierra-blue);
}

/* Profile Field Display */
.profile-field-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.profile-field {
    background: var(--bg-input);
    padding: 12px;
    border-radius: 4px;
    border-left: 3px solid var(--border);
}

.profile-field label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.profile-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Form Styles */
.form-grid {
    display: grid;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

.dark-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.dark-input:focus {
    outline: none;
    border-color: var(--sierra-blue);
}

.action-btn {
    background: var(--sierra-red);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.action-btn:hover {
    opacity: 0.9;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--success-green);
    border-left: 4px solid var(--success-green);
    color: var(--text-primary);
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.toast-notification.error {
    border-color: var(--sierra-red);
    border-left-color: var(--sierra-red);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast-notification.hiding {
    animation: slideOut 0.3s ease-in forwards;
}

.status-tag {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-tag.active {
    background: var(--success-green);
    color: white;
}

.status-tag.inactive,
.status-tag.resigned,
.status-tag.terminated {
    background: #666;
    color: white;
}

/* Certification Status Colors */
.cert-tile {
    background: var(--bg-input);
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.cert-tile:hover {
    background: var(--bg-hover);
}

.cert-tile.cert-status-green {
    border-left-color: #4caf50;
}

.cert-tile.cert-status-yellow {
    border-left-color: #ffc107;
}

.cert-tile.cert-status-red {
    border-left-color: #f44336;
}

.cert-tile.cert-status-expired {
    border-left-color: #666;
    opacity: 0.7;
}

.cert-pulse-red {
    animation: cert-pulse-red-glow 2s infinite;
    border-left-color: #f44336 !important;
}

@keyframes cert-pulse-red-glow {
    0% {
        box-shadow: 0 0 5px rgba(244, 67, 54, 0.4);
        background: var(--bg-input);
    }

    50% {
        box-shadow: 0 0 20px rgba(244, 67, 54, 0.8);
        background: #3d1b1b;
        /* Keep this for pulse effect, but check if readable */
    }

    100% {
        box-shadow: 0 0 5px rgba(244, 67, 54, 0.4);
        background: #2a2a2a;
    }
}

.cert-info {
    flex: 1;
}

.cert-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.cert-expiry {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.cert-expired-badge {
    background: #666;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.cert-actions {
    display: flex;
    gap: 8px;
}

.cert-actions button {
    background: none;
    border: none;
    color: var(--sierra-blue);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 8px;
}

.cert-actions button:hover {
    text-decoration: underline;
}


/* --- Mobile Optimization --- */
@media (max-width: 768px) {

    /* 1. Mobile Flex Ordering */
    .dashboard-grid,
    .dashboard-grid.has-right-col {
        display: flex;
        flex-direction: column;
        gap: 15px;
        padding: 10px;
    }

    /* Secret Sauce: Flatten the columns on mobile! */
    .desktop-col {
        display: contents;
    }

    #memos-card {
        order: 1;
    }

    #lineup-card {
        order: 2;
    }

    #pending-requests-card {
        order: 3;
    }

    #pickup-board-card {
        order: 4;
    }

    #profile-card {
        order: 5;
    }

    #attendance-card {
        order: 6;
    }

    #kudos-widget-card {
        order: 7;
    }

    #certs-card {
        order: 8;
    }

    #annual-reqs-card {
        order: 9;
    }

    #approvals-card {
        order: 10;
    }

    #roster-card {
        order: 99;
        margin-top: 10px;
    }

    /* Navigation handled by style.css */

    .mobile-menu-btn {
        display: block !important;
        /* Force show */
    }

    /* 3. Sticky AOC */
    .aoc-banner {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    /* 4. Unit Cards (Full Width & Larger Text) */
    .unit-grid {
        grid-template-columns: 1fr;
        /* Full width */
    }

    .slot-name {
        font-size: 1.1rem;
        /* Larger for reading */
    }

    .unit-header {
        font-size: 1.2rem;
    }

    /* 5. Touch Targets (Compliance) */
    .compliance-card td {
        padding: 15px 5px !important;
        /* Taller rows */
        font-size: 1rem !important;
    }

    /* Hide Profile Card content initially to save space? User didn't ask, but good practice. Keeping generic. */
}

/* Helper for JS toggle */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
}

/* User Section and Logout Button */
/* --- Premium Sierra Modal Styles --- */
.sierra-modal {
    background: #ffffff !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5) !important;
    border: none !important;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header-premium {
    background: linear-gradient(135deg, #0277bd 0%, #01579b 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header-premium.error-bg {
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
}

.modal-header-premium h2,
.modal-header-premium h3 {
    margin: 0;
    font-size: 1.1rem;
    font-family: var(--font-heading);
    color: white;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000000; /* High enough for most modals */
    backdrop-filter: blur(8px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Specific high-priority z-index for confirmation and badge alerts */
#confirmModal, #unread-kudos-modal {
    z-index: 1100000 !important;
}

#unread-kudos-modal {
    background: rgba(0,0,0,0.92) !important;
}

.close-x-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    transition: background 0.2s;
}

.close-x-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-footer-glass {
    padding: 15px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.sierra-btn-primary {
    background: var(--sierra-blue);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.sierra-btn-primary:hover {
    background: #1e3a8a;
    transform: translateY(-1px);
}

.sierra-btn-primary.danger {
    background: #dc2626;
}

.sierra-btn-primary.danger:hover {
    background: #991b1b;
}

.sierra-btn-secondary {
    background: #e2e8f0;
    color: #475569;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: var(--font-body);
}

.sierra-btn-secondary:hover {
    background: #cbd5e1;
}

.user-name {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.logout-btn {
    background: rgba(244, 67, 54, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(244, 67, 54, 0.4);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(244, 67, 54, 0.3);
    border-color: #ff6b6b;
    transform: translateY(-1px);
}

.compliance-warning {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #c62828;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.compliance-warning ul {
    margin: 5px 0 0 20px;
    padding: 0;
}

.compliance-warning li {
    list-style-type: disc;
}

/* Pickup Board Cards */
.pickup-card {
    background: transparent;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.pickup-card:hover {
    background: var(--bg-hover) !important;
    border-left-color: var(--sierra-blue) !important;
}

/* Memo / Station Note Items */
.memo-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.memo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hidden {
    display: none !important;
}