/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #f8fafc;
    color: #0f172a;
    min-height: 100vh;
    font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
}

/* Container */
.container {
    max-width: 1152px;
    margin: 0 auto;
    padding: 32px 16px;
}

/* Header */
header {
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding-left: 20px;
}

header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.2;
}

header p {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #4f46e5;
    font-weight: 700;
}

.timezone-wrapper {
    background: white;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.timezone-wrapper select {
    outline: none;
    border: none;
    background: transparent;
    font-size: 14px;
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}

@media (min-width: 1024px) {
    .grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .grid main {
        grid-column: span 4;
    }
}

/* Sidebar */
aside {
    position: fixed;
    left: 20px;
    top: 140px;
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Card Styles */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
    border: 1px solid #e5e7eb;
    padding: 24px;
}

.card h3 {
    font-weight: 700;
    margin-bottom: 12px;
}

/* Input Styles */
input[type="date"] {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px;
    font-size: 14px;
}

input[type="date"]:first-of-type {
    margin-bottom: 8px;
}

input[type="checkbox"] {
    cursor: pointer;
}

/* Offset Section */
.offset-section {
    margin-top: 16px;
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
}

.offset-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px 0;
}

.offset-title {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}

.offset-toggle {
    font-weight: 700;
    color: #4f46e5;
}

.offset-content {
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.offset-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.offset-row label {
    font-size: 12px;
    color: #64748b;
    width: 100px;
}

.offset-row input {
    width: 80px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px;
    font-size: 13px;
}

#apply-offset-btn {
    width: 100%;
    margin-top: 4px;
    padding: 10px;
    background-color: #8b5cf6;
    color: white;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    border: none;
    cursor: pointer;
}

/* Button Styles */
button {
    width: 100%;
    padding: 12px;
    height: 35px;
    border-radius: 6px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

button:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#load-btn {
    background-color: #4f46e5;
    color: white;
    margin-top: 16px;
}

#generate-btn {
    background-color: #4f46e5;
    color: white;
    margin-top: 8px;
}

#download-btn {
    background-color: #64748b;
    color: white;
    margin-top: 8px;
}

#csv-btn {
    background-color: #64748b;
    color: white;
    margin-top: 8px;
}

#import-csv-btn {
    background-color: #10b981;
    color: white;
    margin-top: 8px;
}

#prev, #next {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e5e7eb;
    width: auto;
    height: auto;
}

#prev:hover, #next:hover {
    transform: none;
}

/* League List */
#league-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.league-wrapper {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

.league-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: #f1f5f9;
    font-weight: 700;
    color: #4338ca;
    cursor: pointer;
}

.league-content {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
}

.league-content label {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.875rem;
    color: #334155;
    cursor: pointer;
}

/* Schedule Container */
#schedule-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Section Title */
.section-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #94a3b8;
    text-transform: uppercase;
}

/* Carousel */
#carousel-wrap {
    margin-top: 16px;
    text-align: center;
}

#carousel-slides {
    transform: scale(.75);
    transform-origin: top center;
    width: 1080px;
    margin: 0 auto;
    position: relative;
    display: flex;
    justify-content: center;
    overflow: visible;
    margin-bottom: -300px;
}

.carousel-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 4px;
}

#counter {
    font-weight: 700;
}

/* Loader */
.loader {
    border: 4px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1.2s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-wrapper {
    display: flex;
    justify-content: center;
    padding: 80px 0;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center { text-align: center; }
.flex { display: flex; }
.justify-center { justify-content: center; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

/* Control Panel */
#control-panel {
    position: fixed;
    right: 20px;
    top: 140px;
    width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,.1);
    border: 1px solid #e5e7eb;
    padding: 24px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    z-index: 1000;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.control-header h3 {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
}

#current-slide-num {
    font-size: 0.9rem;
    font-weight: 600;
    color: #4f46e5;
}

.control-section {
    margin-bottom: 20px;
}

.control-section label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 8px;
}

.control-section input[type="text"],
.control-section input[type="number"],
.control-section select,
.control-section textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.control-section input[type="color"] {
    width: 60px;
    height: 40px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.control-section input[type="range"] {
    width: calc(100% - 70px);
    margin-left: 10px;
    vertical-align: middle;
}

#opacity-value, #outline-opacity-value {
    display: inline-block;
    width: 50px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#reset-slide-btn {
    width: 100%;
    padding: 10px;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    margin-top: 12px;
}

#reset-slide-btn:hover {
    background-color: #dc2626;
}

/* Match Card Styles for Generated Slides */
.match-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    width: 460px;
    height: 140px;
    padding: 18px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.match-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-time {
    font-weight: 600;
    font-size: 20px;
    line-height: 20px;
}

.match-league {
    color: #d8b4fe;
    font-size: 14px;
    line-height: 14px;
    font-weight: 500;
}

.match-teams {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.team-name {
    font-weight: 600;
    font-size: 22px;
    line-height: 26px;
}

.team-name.away {
    text-align: right;
}

.vs-text {
    color: #d8b4fe;
    font-size: 14px;
    line-height: 14px;
    font-weight: 500;
}

.match-channel {
    text-align: center;
    color: #d8b4fe;
    font-size: 14px;
    line-height: 14px;
}

/* Helper classes for refactored HTML */
.primary-btn-sm {
    width: 100%; 
    padding: 8px; 
    margin-top: 8px; 
    background: #4f46e5; 
    color: white; 
    border: none; 
    border-radius: 6px; 
    font-weight: 600; 
    font-size: 13px;
}

.control-divider {
    border: none; 
    border-top: 1px solid #e5e7eb; 
    margin: 16px 0;
}

.control-label-bold {
    font-weight: 700; 
    margin-bottom: 12px; 
    display: block;
}

.control-grid-2 {
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px;
}

.sub-label {
    font-size: 12px; 
    color: #64748b; 
    margin-bottom: 4px; 
    display: block;
}

.btn-group {
    display: flex; 
    gap: 6px;
}

.alignment-btn {
    flex: 1; 
    padding: 6px; 
    background: white; 
    border: 1px solid #e5e7eb; 
    border-radius: 6px; 
    font-size: 14px; 
    cursor: pointer; 
    transition: all 0.2s;
}

.control-grid-1 {
    display: grid; 
    gap: 12px;
}

.control-row {
    display: flex; 
    align-items: center; 
    gap: 8px;
}

.width-input {
    width: 70px !important;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    aside {
        position: static;
        width: 100%;
    }
}