/* ==================== 1. GLOBAL LAYOUT ==================== */
:root {
    --header-height: 45px;
    --modal-bg-color: rgba(255, 255, 255, 0.92);
    --modal-blur: 12px;
}

.main-container {
    margin: 20px auto;
    width: 100%;
    max-width: none;
    display: block;
    gap: 0px; 
}

/* Spacing between Header Card and Tabs */
.main-container > .game-card:first-child { margin-bottom: 5px; }

.empty-state {
    grid-column: 1 / -1; 
    width: 100%;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #888);
    font-size: 0.95em;
    font-style: italic;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.full-width { width: 100%; }
.mt-auto { margin-top: auto; }
.mt-16 { margin-top: 16px; }

/* Loading Spinner */
.loading-spinner-container { display: flex; justify-content: center; padding: 40px; width: 100%; }
.spinner { border: 4px solid rgba(0, 0, 0, 0.1); border-left-color: var(--primary-color); border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }


/* ==================== 2. TABS & NAVIGATION ==================== */
.game-tab-bar {
    display: flex; gap: 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 20px; margin-top: 15px;
}

.game-tab-btn {
    background: transparent; border: none; padding: 12px 24px;
    font-family: var(--font-ui); font-weight: 600; color: var(--text-secondary);
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center; gap: 8px; 
}

.game-tab-btn:hover { color: var(--primary-color); background-color: rgba(0,0,0,0.02); }
.game-tab-btn.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }

.tab-icon { display: none; font-size: 1.2em; }
.tab-text { display: inline; }

.badge {
    display: inline-block; background: var(--c-accent-01); color: white;
    border-radius: 10px; padding: 2px 6px; font-size: 0.75em;
    margin-left: 6px; line-height: 1; vertical-align: middle;
}

.tab-content { display: none !important; flex-direction: column; gap: 20px; animation: fadeIn 0.2s ease; }
.tab-content.active { display: flex !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }


/* ==================== 3. SHOW / CAREER CARDS ==================== */
.career-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 0;
}

/* Base Card Style */
.career-card, .show-card {
    cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex; align-items: start; gap: 10px; padding: 12px; 
    border-radius: 8px; border: 1px solid var(--border-light);
    background-color: var(--bg-main);
    background-size: cover; background-repeat: no-repeat; background-position: bottom center; 
    min-height: 135px; position: relative; overflow: hidden; z-index: 1;
    color: white; /* Ensure text is white on dark bg */
}

/* Gradient Overlay */
.career-card::before, .show-card::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(82, 82, 82, 0.1) 0%, rgba(82, 82, 82, 0.05) 40%, rgba(82, 82, 82, 0.0) 100%);
    z-index: -1; pointer-events: none;
}

.career-card:hover, .show-card:not(.disabled):hover { 
    transform: translateY(-2px); 
    box-shadow: var(--shadow-md); 
    border-color: rgba(255,255,255,0.8); 
}
.career-card:hover::before, .show-card:not(.disabled):hover::before { 
    background: rgba(255,255,255,0); 
}

/* Specific Show Card Layout */
.show-card {
    flex-direction: column; /* Shows stack vertically */
    min-height: 160px;
}

.show-card-content {
    flex: 1; display: flex; flex-direction: column; width: 100%;
}

/* Disabled State (Glassine) */
.show-card.disabled {
    opacity: 0.6; cursor: default; pointer-events: none; filter: grayscale(0.05);
}
.show-card.disabled::before {
    background: rgba(0,0,0,0.05); backdrop-filter: blur(3px);
}
.show-card.disabled::after {
    content: "NO ELIGIBLE HORSES";
    text-align: center; position: absolute; top: 60%; left: 50%; transform: translate(-50%, -50%);
    font-size: 0.8em; font-weight: 800; color: rgba(255,255,255,0.8);
    border: 2px solid rgba(255,255,255,0.5); padding: 4px 8px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: 1px; z-index: 10;
}
.show-card.disabled .action-arrow { display: none; }

/* Icon Box */
.career-icon {
    width: 38px; height: 38px; background: rgba(255,255,255,0.15);
    backdrop-filter: blur(4px); border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.2em; flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Typography */
.career-title, .show-card .show-title { 
    margin: 0 0 2px 0; font-size: 1.1em; color: white; font-weight: 650; 
    line-height: 1.1; letter-spacing: 0.5px; text-transform: uppercase; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.career-skills-text, .prize-text { 
    font-size: 0.7em; color: rgba(255,255,255,0.8); text-transform: uppercase; 
    letter-spacing: 0.5px; font-weight: 600; margin-bottom: 8px; line-height: 1.3;
}

/* Title */
.show-title {
    font-size: 1.4em;
    color: #443937;
    font-weight: 700;
    font-family: 'Quicksand', sans-serif;
    margin-bottom: 10px;
    line-height: 1.3;
}

/* Footer & Arrow */
.career-footer { display: flex; align-items: center; margin-top: auto; height: 24px; width: 100%; }
.action-arrow { 
    position: absolute; bottom: 12px; right: 12px;
    color: rgba(255,255,255,0.6); font-size: 0.9em; transition: all 0.2s ease; 
}
.career-card:hover .action-arrow, .show-card:hover .action-arrow { 
    color: #fff; transform: translateX(2px); 
}

/* Status Ribbon */
.status-ribbon {
    position: absolute; top: -4px; right: 12px; width: 28px; height: 42px;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    padding-top: 8px; color: #fff; font-size: 0.75em; font-weight: 700;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
    z-index: 10; background: var(--c-accent-01, #3b82f6); line-height: 1;
}
.ribbon-icon { font-size: 0.8em; margin-bottom: 2px; }
.status-ribbon.ready { background: var(--go-green); }
.status-ribbon.busy { background: var(--go-yellow); }


/* ==================== 4. ACTIVE ENTRIES ==================== */
.shifts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 0; }
.header-with-action { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-light); padding-bottom: 10px; margin-bottom: 15px; }
.header-with-action .card-section-heading { margin: 0; padding-bottom: 0; border-bottom: none; line-height: 1; }

.active-shift-card {
    background-color: var(--bg-main); background-size: 110%; background-position: center 95%; background-repeat: no-repeat;
    display: flex; flex-direction: column; justify-content: flex-start; gap: 6px;
    height: 100px; padding: 12px; padding-right: 12px; 
    border: 1px solid var(--border-light); border-radius: 8px; position: relative; overflow: hidden; z-index: 1; transition: all 0.2s ease;
    opacity: 0.9; filter: grayscale(0.05); cursor: default;
}

.active-shift-card::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(82, 82, 82, 0.1) 0%, rgba(82, 82, 82, 0.05) 40%, rgba(82, 82, 82, 0.0) 100%);
    z-index: -1; pointer-events: none; transition: all 0.3s ease;
}

.active-shift-card.ready { cursor: pointer; padding-right: 20px; opacity: 1; filter: grayscale(0); }
.active-shift-card.ready:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(74, 222, 128, 0.2); }
.active-shift-card.ready:hover::before { background: none; }

.collect-strip {
    position: absolute; right: 0; top: 0; bottom: 0; width: 25px;
    background: var(--go-green); color: var(--c-page-bg, #fff);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-ui); font-weight: 800; font-size: 0.7em; letter-spacing: 2px;
    text-transform: uppercase; writing-mode: vertical-rl; text-orientation: mixed;
    opacity: 0; transform: translateX(100%) rotate(180deg); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 2;
}
.active-shift-card.ready .collect-strip { opacity: 1; transform: translateX(0) rotate(180deg); }

.shift-info { display: flex; flex-direction: column; gap: 2px; transition: opacity 0.2s; }
.shift-horse-name { font-weight: 650; font-size: .9em; color: #4a4a4a; opacity: .9; text-transform: uppercase; line-height:1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.5px; }
.shift-job-name { font-size: 0.7em; color: #4a4a4a; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; opacity: 0.7; }

.shift-timer-container { align-self: flex-start; width: 100%; margin-top: 4px; }
.timer-text { font-family: var(--font-ui); font-weight: 600; color: #4a4a4a; font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; }
.timer-text i { color: #4a4a4a; font-size: 1.1em; }
.active-shift-card.ready .timer-text { display: none; }

/* Buttons */
.game-btn.compact { padding: 6px 16px; font-size: 0.8em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border-radius: 4px; border: none; cursor: pointer; background-color: var(--go-green); color: white; }


/* ==================== 5. ROSTER TABLE ==================== */
#roster-tab-content .game-card { padding-top: 0; }
#roster-table { width: 100%; border-collapse: collapse; }

#roster-table thead th {
    font-family: var(--font-ui); font-size: 0.8em; font-weight: 600; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.08em; padding: 0px 16px 10px 16px; 
    border-bottom: 1px solid var(--border-light); text-align: left; background: transparent;
}
#roster-table thead th.text-center, #roster-table tbody td.text-center { text-align: center !important; }

#roster-table tbody td {
    padding: 12px 16px; border-bottom: 1px solid var(--border-light); color: var(--text-primary); font-size: 0.85em; vertical-align: middle;
}
#roster-table tbody tr:last-child td { border-bottom: none; }
#roster-table thead th:first-child, #roster-table tbody td:first-child { padding-left: 0; }

.roster-horse-link strong { display: block; font-family: var(--font-ui); font-weight: 700; font-size: 0.85em; color: #4a4a4a; opacity: 0.9; text-transform: uppercase; line-height: 1em; letter-spacing: 0.5px; transition: color 0.2s; }
.roster-horse-link:hover strong { color: var(--primary-color); opacity: 1; }

.icon-circle { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; vertical-align: middle; margin-left: 4px; }
.icon-circle.small { width: 22px; height: 22px; font-size: 0.75em; }


/* ==================== 6. MODAL & SCHEDULER (Registry Style) ==================== */
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000; opacity: 1; transition: opacity 0.2s ease;
}
.modal-backdrop.hidden { opacity: 0; pointer-events: none; visibility: hidden; }

/* The Scheduler Card (Transparent, Floating look) */
.modal-content.scheduler-card { 
    width: auto; max-width: 95vw; height: auto; max-height: 85vh;
    background-color: rgba(179, 179, 179, 0); /* Transparent */
    border-radius: 12px; border: none;
    display: flex; flex-direction: column;
}

.scheduler-card .card-header {
    background: transparent; border-bottom: 1px solid rgba(255, 255, 255, 0.2); 
    padding: 16px 24px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
}
/* Force White Text on Dark Modal */
.scheduler-card .card-section-heading { color: #ffffff !important; margin: 0; font-size: 1.3em; }
.scheduler-card .icon-btn { color: #ffffff !important; background: transparent; border: none; font-size: 1.2em; cursor: pointer; }

/* Body Layout */
.scheduler-layout.grid-mode {
    display: block; padding: 24px; background: transparent; overflow-y: auto;
}

.roster-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }

/* Horse Card inside Modal */
.horse-shift-card {
    width: 220px; background: #fff;
    border: 1px solid var(--border-light, #e0e0e0);
    border-radius: 8px; padding: 12px;
    display: flex; flex-direction: column; gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: transform 0.2s ease;
}
.horse-shift-card:hover { transform: translateY(-2px); border-color: var(--primary-color); }

.hsc-header { display: flex; justify-content: space-between; align-items: center; }
.hsc-name { font-weight: 700; font-size: 0.9em; color: #333; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.hsc-ap { font-weight: 700; color: var(--c-accent-01, #e67e22); font-size: 0.85em; }
.hsc-tier { font-size: 0.75em; color: var(--text-secondary, #666); text-transform: uppercase; margin-top: -4px; }
.hsc-divider { height: 1px; background-color: #eee; width: 100%; margin: 4px 0; }
.hsc-stat-row { display: flex; justify-content: space-between; font-size: 0.85em; color: #555; }
.hsc-stat-val { font-weight: 700; color: #333; }

.hsc-btn {
    width: 100%; margin-top: 8px; padding: 8px;
    border: none; border-radius: 4px;
    background-color: var(--primary-color, #3b82f6);
    color: white; font-weight: 700; text-transform: uppercase; font-size: 0.8em;
    cursor: pointer; transition: background 0.2s;
}
.hsc-btn:hover:not(:disabled) { filter: brightness(1.1); }
.hsc-btn:disabled { background-color: #ccc; cursor: not-allowed; opacity: 0.8; }
.hsc-btn.entered { background-color: #10b981; cursor: default; }

/* Empty State (Text must be white on dark) */
.scheduler-empty-state {
    grid-column: 1 / -1; max-width: 500px; margin: 0 auto; text-align: center; padding: 40px;
}
.scheduler-empty-state .game-text { color: rgba(255,255,255,0.9) !important; }


/* ==================== 7. MOBILE RESPONSIVE ==================== */
@media (max-width: 800px) {
    /* Tablet adjustments if needed */
}

@media (max-width: 640px), (max-width: 900px) and (orientation: portrait) {
    .main-container { padding: 0 16px; }
    
    /* 1. Simplify Main Tabs & Grid */
    .career-grid, .shifts-grid { grid-template-columns: 1fr; }
    
    .game-tab-bar { flex-wrap: nowrap; justify-content: space-around; }
    .tab-text { display: none; }
    .tab-icon { display: inline-block; margin: 0; font-size: 1.1em; }
    .badge { position: absolute; top: 6px; right: 20%; border: 2px solid #fff; }
    
    .header-with-action { padding-bottom: 8px; margin-bottom: 12px; gap: 10px; }
    .header-with-action .card-section-heading { white-space: nowrap; font-size: 1.1em; }
    
    /* 2. Full Screen Modal */
    body.modal-open { overflow: hidden; }
    
    .modal-backdrop { 
        display: flex; align-items: flex-start; justify-content: center;
        background: rgba(0,0,0,0.85); padding: 0; 
    }
    
    .modal-content.scheduler-card {
        width: 100%; height: auto; position: fixed; top: var(--header-height); bottom: 0; left: 0; right: 0;
        max-width: 100%; max-height: none; border-radius: 0; border: none; 
        background-color: transparent; 
    }
    
    .scheduler-card .card-header { 
        background: transparent; padding: 12px 16px; 
        border-bottom: 1px solid rgba(255, 255, 255, 0.2); flex-shrink: 0; 
    }
    
    .scheduler-card .card-header .card-section-heading { color: #ffffff !important; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
    .scheduler-card .icon-btn { color: #ffffff !important; }

    /* 3. Tighter Grid Layout */
    .scheduler-layout.grid-mode { padding: 12px; overflow-y: auto; padding-bottom: 80px; }
    
    .roster-grid { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 10px; justify-content: stretch !important; }
    .horse-shift-card { width: 100% !important; padding: 10px; background: #fff; }
    
    .hsc-name { font-size: 0.8em; }
    .hsc-btn { padding: 6px; font-size: 0.75em; }

    /* 4. Mobile Roster Table (List View) */
    #roster-table, #roster-table thead, #roster-table tbody { display: block; width: 100%; }
    
    #roster-table thead { display: flex; gap: 12px; padding: 0 0 10px 0; border-bottom: 2px solid var(--border-light); }
    #roster-table thead th:nth-child(2), #roster-table thead th:nth-child(3) { display: none; }
    #roster-table thead th:nth-child(1) { flex: 1; text-align: left; padding: 0; border: none; }
    #roster-table thead th:nth-child(4) { min-width: 40px; text-align: center; padding: 0; border: none; display: block; }
    #roster-table thead th:nth-child(5) { min-width: 60px; text-align: right; padding: 0; border: none; display: block; }
    
    #roster-table tbody tr { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
    #roster-table tbody td { display: none; padding: 0; border: none; }
    
    #roster-table tbody td:first-child { display: flex; flex-direction: column; gap: 2px; flex: 1; text-align: left; }
    #roster-table tbody td:first-child strong { font-size: 0.9em; }
    #roster-table tbody td:first-child::after { content: attr(data-job); display: block; font-size: 0.7em; font-weight: 400; color: var(--text-secondary); }
    
    #roster-table tbody td:nth-child(4) { display: flex; align-items: center; justify-content: center; font-family: monospace; font-weight: 600; min-width: 40px; }
    #roster-table tbody td:nth-child(5) { display: flex; align-items: center; justify-content: flex-end; min-width: 60px; }
}