/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    overflow-x: hidden;
}

/* Product Header */
.product-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.product-info {
    max-width: 800px;
    margin: 0 auto;
}

.product-name {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.product-slogan {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 16px;
    opacity: 0.9;
    color: #ecf0f1;
}

.product-description {
    font-size: 1rem;
    line-height: 1.6;
    opacity: 0.85;
    color: #bdc3c7;
    max-width: 600px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .product-header {
        padding: 30px 15px;
    }
    
    .product-name {
        font-size: 2rem;
    }
    
    .product-slogan {
        font-size: 1.1rem;
    }
    
    .product-description {
        font-size: 0.95rem;
    }
}

/* Main app container */
.app-container {
    display: flex;
    min-height: 100vh;
    gap: 20px;
    padding: 20px;
}

/* Control Panel (Left Sidebar) */
.control-panel {
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 24px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.control-panel h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
    color: #2c3e50;
    text-align: center;
}

.control-panel h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #34495e;
}

.control-section {
    margin-bottom: 32px;
}

/* Download PDF Button */
.download-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 32px;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Print Button */
.print-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 32px;
}

.print-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

/* Theme Gallery */
.theme-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.theme-option {
    width: 60px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.theme-option:hover {
    transform: scale(1.05);
    border-color: #667eea;
}

.theme-option.active {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* Font Controls */
.control-section select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.control-section select:focus {
    outline: none;
    border-color: #667eea;
}

/* Upload and Remove Buttons */
.upload-btn, .remove-btn {
    width: 100%;
    padding: 12px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.upload-btn:hover {
    background: #667eea;
    color: white;
}

.remove-btn {
    border-color: #e74c3c;
    color: #e74c3c;
}

.remove-btn:hover {
    background: #e74c3c;
    color: white;
}

/* Color Picker */
.color-picker-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

#custom-color-picker {
    width: 60px;
    height: 40px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    cursor: pointer;
    background: none;
    padding: 0;
}

#custom-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
    border: none;
    border-radius: 4px;
}

#custom-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.apply-color-btn {
    flex: 1;
    padding: 10px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.apply-color-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

/* Transparency Control */
.transparency-control {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e1e8ed;
}

.transparency-control label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #34495e;
    margin-bottom: 8px;
}

.opacity-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e1e8ed;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 8px;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.opacity-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#opacity-value {
    font-size: 12px;
    font-weight: 500;
    color: #667eea;
    text-align: center;
    display: block;
}

/* Structure Controls */
.structure-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 14px;
    font-weight: 500;
    color: #34495e;
    min-width: 60px;
}

.structure-btn {
    padding: 8px 12px;
    border: 2px solid #27ae60;
    background: white;
    color: #27ae60;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.structure-btn:hover {
    background: #27ae60;
    color: white;
}

.structure-btn.remove {
    border-color: #e74c3c;
    color: #e74c3c;
}

.structure-btn.remove:hover {
    background: #e74c3c;
    color: white;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 0;
}

/* Schedule Canvas - Fixed Aspect Ratio (8.5:11) */
.schedule-canvas {
    position: relative;
    width: 100%;
    max-width: 680px; /* Optimized for screen viewing */
    aspect-ratio: 8.5 / 11; /* US Letter aspect ratio */
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: auto;
    border: 1px solid #e1e8ed;
    padding: 20px;
    box-sizing: border-box;
}

/* Custom Scrollbar Styling */
.schedule-canvas::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.schedule-canvas::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.schedule-canvas::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.schedule-canvas::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.schedule-canvas::-webkit-scrollbar-corner {
    background: #f1f1f1;
}

/* Canvas Background for uploaded images */
.canvas-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.1;
    z-index: 1;
}

/* CSS Custom Properties */
:root {
    --day-column-width: 22%; /* Default for 4 day columns */
}

/* Schedule Title */
.schedule-title {
    position: relative;
    z-index: 10;
    text-align: center;
    margin: 0 0 20px 0;
    padding: 10px;
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
    border: 2px dashed transparent;
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
    cursor: text;
}

.schedule-title:hover {
    border-color: #bdc3c7;
    background-color: #f8f9fa;
}

.schedule-title:focus {
    border-color: #3498db;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Schedule Table */
.schedule-table {
    position: relative;
    z-index: 2;
    width: 100%;
    min-width: 600px; /* Minimum width to ensure horizontal scrolling when needed */
    height: calc(100% - 40px);
    min-height: 400px; /* Minimum height to ensure vertical scrolling when needed */
    border-collapse: collapse;
    font-family: inherit;
}

.schedule-table th,
.schedule-table td {
    border: 1px solid rgb(221, 221, 221);
    text-align: center;
    vertical-align: middle;
    position: relative;
}

/* Table Header */
.schedule-table th {
    background-color: rgb(248, 249, 250);
    font-weight: bold;
    color: #2c3e50;
    padding: 12px 8px;
    font-size: 14px;
}

/* Time Column */
.time-column {
    width: 12%;
    min-width: 80px;
}

.time-slot {
    background-color: rgb(236, 240, 241);
    font-weight: bold;
    color: #34495e;
    padding: 8px 4px;
    font-size: 12px;
    width: 12%;
    min-width: 80px;
}

/* Class Cells - Dynamic width calculation */
.class-cell {
    padding: 8px 6px;
    min-height: 40px;
    cursor: text;
    transition: background-color 0.2s;
    font-size: 13px;
    line-height: 1.3;
    min-width: 100px;
    width: var(--day-column-width);
    background-color: white;
}

/* Dynamic column width calculation */
.schedule-table {
    table-layout: auto;
}

.schedule-table th:not(.time-column),
.schedule-table td:not(.time-slot) {
    width: var(--day-column-width);
}

.class-cell:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

.class-cell:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
    background-color: rgba(102, 126, 234, 0.1);
}

/* Placeholder styling */
.class-cell:empty:before {
    content: attr(data-placeholder);
    color: #bbb;
    font-style: italic;
    pointer-events: none;
}

.class-cell:focus:before {
    display: none;
}

/* Font Size Classes */
.font-small {
    font-size: 11px;
}

.font-medium {
    font-size: 13px;
}

.font-large {
    font-size: 15px;
}

.font-small .time-slot {
    font-size: 10px;
}

.font-medium .time-slot {
    font-size: 12px;
}

.font-large .time-slot {
    font-size: 14px;
}

.font-small th {
    font-size: 12px;
}

.font-medium th {
    font-size: 14px;
}

.font-large th {
    font-size: 16px;
}

/* Theme Styles - Text Color Only (matching PDF output) */
.schedule-canvas {
    background: white;
}

/* Ensure consistent background colors regardless of theme */
.schedule-table th {
    background-color: rgb(248, 249, 250) !important;
}

.time-slot {
    background-color: rgb(236, 240, 241) !important;
}

.class-cell {
    background-color: white !important;
}

.schedule-table th,
.schedule-table td {
    border: 1px solid rgb(221, 221, 221) !important;
}

/* Theme styles - Text color only (matching PDF output) */
.theme-default,
.theme-default .schedule-title,
.theme-default .schedule-table,
.theme-default .schedule-table th,
.theme-default .schedule-table td,
.theme-default .class-cell,
.theme-default .time-slot {
    color: #2c3e50 !important;
}

.theme-classic,
.theme-classic .schedule-title,
.theme-classic .schedule-table,
.theme-classic .schedule-table th,
.theme-classic .schedule-table td,
.theme-classic .class-cell,
.theme-classic .time-slot {
    color: #8b4513 !important;
}

.theme-modern,
.theme-modern .schedule-title,
.theme-modern .schedule-table,
.theme-modern .schedule-table th,
.theme-modern .schedule-table td,
.theme-modern .class-cell,
.theme-modern .time-slot {
    color: #4682b4 !important;
}

.theme-vibrant,
.theme-vibrant .schedule-title,
.theme-vibrant .schedule-table,
.theme-vibrant .schedule-table th,
.theme-vibrant .schedule-table td,
.theme-vibrant .class-cell,
.theme-vibrant .time-slot {
    color: #9b59b6 !important;
}

.theme-nature,
.theme-nature .schedule-title,
.theme-nature .schedule-table,
.theme-nature .schedule-table th,
.theme-nature .schedule-table td,
.theme-nature .class-cell,
.theme-nature .time-slot {
    color: #27ae60 !important;
}

.theme-sunset,
.theme-sunset .schedule-title,
.theme-sunset .schedule-table,
.theme-sunset .schedule-table th,
.theme-sunset .schedule-table td,
.theme-sunset .class-cell,
.theme-sunset .time-slot {
    color: #e67e22 !important;
}

.theme-custom,
.theme-custom .schedule-title,
.theme-custom .schedule-table,
.theme-custom .schedule-table th,
.theme-custom .schedule-table td,
.theme-custom .class-cell,
.theme-custom .time-slot {
    color: var(--custom-text-color, #2c3e50) !important;
}

/* Theme colors using data-theme attribute */
[data-theme="default"],
[data-theme="default"] .schedule-title,
[data-theme="default"] .schedule-table,
[data-theme="default"] .schedule-table th,
[data-theme="default"] .schedule-table td,
[data-theme="default"] .class-cell,
[data-theme="default"] .time-slot {
    color: #2c3e50 !important;
}

[data-theme="classic"],
[data-theme="classic"] .schedule-title,
[data-theme="classic"] .schedule-table,
[data-theme="classic"] .schedule-table th,
[data-theme="classic"] .schedule-table td,
[data-theme="classic"] .class-cell,
[data-theme="classic"] .time-slot {
    color: #8b4513 !important;
}

[data-theme="modern"],
[data-theme="modern"] .schedule-title,
[data-theme="modern"] .schedule-table,
[data-theme="modern"] .schedule-table th,
[data-theme="modern"] .schedule-table td,
[data-theme="modern"] .class-cell,
[data-theme="modern"] .time-slot {
    color: #4682b4 !important;
}

[data-theme="vibrant"],
[data-theme="vibrant"] .schedule-title,
[data-theme="vibrant"] .schedule-table,
[data-theme="vibrant"] .schedule-table th,
[data-theme="vibrant"] .schedule-table td,
[data-theme="vibrant"] .class-cell,
[data-theme="vibrant"] .time-slot {
    color: #9b59b6 !important;
}

[data-theme="nature"],
[data-theme="nature"] .schedule-title,
[data-theme="nature"] .schedule-table,
[data-theme="nature"] .schedule-table th,
[data-theme="nature"] .schedule-table td,
[data-theme="nature"] .class-cell,
[data-theme="nature"] .time-slot {
    color: #27ae60 !important;
}

[data-theme="sunset"],
[data-theme="sunset"] .schedule-title,
[data-theme="sunset"] .schedule-table,
[data-theme="sunset"] .schedule-table th,
[data-theme="sunset"] .schedule-table td,
[data-theme="sunset"] .class-cell,
[data-theme="sunset"] .time-slot {
    color: #e67e22 !important;
}

[data-theme="custom"],
[data-theme="custom"] .schedule-title,
[data-theme="custom"] .schedule-table,
[data-theme="custom"] .schedule-table th,
[data-theme="custom"] .schedule-table td,
[data-theme="custom"] .class-cell,
[data-theme="custom"] .time-slot {
    color: var(--custom-text-color, #2c3e50) !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }
    
    .control-panel {
        width: 100%;
        position: static;
    }
    
    .schedule-canvas {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .control-panel {
        padding: 16px;
    }
    
    .theme-gallery {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .theme-option {
        width: 40px;
        height: 30px;
    }
    
    .class-cell {
        font-size: 11px;
        padding: 6px 4px;
        min-height: 35px;
    }
    
    .schedule-table th {
        font-size: 12px;
        padding: 8px 4px;
    }
    
    .time-slot {
        font-size: 10px;
        padding: 6px 2px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .control-panel {
        display: none;
    }
    
    .app-container {
        padding: 0;
        margin: 0;
    }
    
    .canvas-container {
        padding: 0;
        margin: 0;
    }
    
    .schedule-canvas {
        width: 8.5in;
        height: 11in;
        max-width: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
    }
}