/* Variables CSS para temas */
:root {
    /* Tema claro (por defecto) */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-sidebar: #2c3e50;
    --bg-sidebar-item: #34495e;
    --bg-input: #ffffff;
    --bg-date-selection: #34495e;
    
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-sidebar: #ecf0f1;
    --text-muted: #95a5a6;
    --text-light: #bdc3c7;
    
    --accent-primary: #3498db;
    --accent-primary-hover: #2980b9;
    --accent-secondary: #95a5a6;
    --accent-secondary-hover: #7f8c8d;
    --accent-danger: #e74c3c;
    --accent-danger-hover: #c0392b;
    
    --border-color: #ddd;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --modal-overlay: rgba(0, 0, 0, 0.6);
    
    --scrollbar-track: #34495e;
    --scrollbar-thumb: #3498db;
    --scrollbar-thumb-hover: #2980b9;
}

/* Tema oscuro */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a2e;
        --bg-secondary: #16213e;
        --bg-sidebar: #0f0f23;
        --bg-sidebar-item: #1a1a2e;
        --bg-input: #2a2a4a;
        --bg-date-selection: #1a1a2e;
        
        --text-primary: #e4e4e7;
        --text-secondary: #a1a1aa;
        --text-sidebar: #e4e4e7;
        --text-muted: #71717a;
        --text-light: #a1a1aa;
        
        --accent-primary: #6366f1;
        --accent-primary-hover: #4f46e5;
        --accent-secondary: #52525b;
        --accent-secondary-hover: #3f3f46;
        --accent-danger: #ef4444;
        --accent-danger-hover: #dc2626;
        
        --border-color: #3f3f46;
        --shadow-color: rgba(0, 0, 0, 0.4);
        --modal-overlay: rgba(0, 0, 0, 0.8);
        
        --scrollbar-track: #1a1a2e;
        --scrollbar-thumb: #6366f1;
        --scrollbar-thumb-hover: #4f46e5;
    }
}

/* Clase para forzar tema oscuro manualmente */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-sidebar: #0f0f23;
    --bg-sidebar-item: #1a1a2e;
    --bg-input: #2a2a4a;
    --bg-date-selection: #1a1a2e;
    
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-sidebar: #e4e4e7;
    --text-muted: #71717a;
    --text-light: #a1a1aa;
    
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    --accent-secondary: #52525b;
    --accent-secondary-hover: #3f3f46;
    --accent-danger: #ef4444;
    --accent-danger-hover: #dc2626;
    
    --border-color: #3f3f46;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --modal-overlay: rgba(0, 0, 0, 0.8);
    
    --scrollbar-track: #1a1a2e;
    --scrollbar-thumb: #6366f1;
    --scrollbar-thumb-hover: #4f46e5;
}

/* Clase para forzar tema claro manualmente */
[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-sidebar: #2c3e50;
    --bg-sidebar-item: #34495e;
    --bg-input: #ffffff;
    --bg-date-selection: #34495e;
    
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-sidebar: #ecf0f1;
    --text-muted: #95a5a6;
    --text-light: #bdc3c7;
    
    --accent-primary: #3498db;
    --accent-primary-hover: #2980b9;
    --accent-secondary: #95a5a6;
    --accent-secondary-hover: #7f8c8d;
    --accent-danger: #e74c3c;
    --accent-danger-hover: #c0392b;
    
    --border-color: #ddd;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --modal-overlay: rgba(0, 0, 0, 0.6);
    
    --scrollbar-track: #34495e;
    --scrollbar-thumb: #3498db;
    --scrollbar-thumb-hover: #2980b9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 10px var(--shadow-color);
    transition: background-color 0.3s ease;
}

.sidebar h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-sidebar);
    text-align: center;
}

.sidebar h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 5px;
}

.section {
    margin-bottom: 30px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: var(--text-sidebar);
}

input[type="month"],
input[type="number"],
input[type="text"],
input[type="date"],
select {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

input[type="month"]:focus,
input[type="number"]:focus,
input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 10px;
}

button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
}

.btn-secondary {
    background: var(--accent-secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--accent-secondary-hover);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: var(--accent-danger-hover);
}

/* Tag Form */
.tag-form {
    display: flex;
    flex-direction: column;
}

/* Weekend option */
.weekend-option {
    display: flex;
    align-items: center;
    gap: 10px;
}

.weekend-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
    margin-bottom: 0;
}

.weekend-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.weekend-option input[type="color"] {
    width: 40px;
    height: 30px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.tags-list {
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.tag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg-sidebar-item);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.tag-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.tag-color-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    margin-right: 10px;
}

.tag-name {
    font-size: 14px;
}

.tag-day-count {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 5px;
}

.tag-delete {
    background: var(--accent-danger);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    width: auto;
    min-width: 32px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
}

.tag-delete:hover {
    background: var(--accent-danger-hover);
}

.tag-edit {
    background: transparent;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    width: auto;
    min-width: 32px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    transition: background 0.2s;
}

.tag-edit:hover {
    background: rgba(99, 102, 241, 0.3);
}

.tag-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Periods List */
.periods-list {
    margin-top: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.period-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg-sidebar-item);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.period-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.period-color-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 10px;
    flex-shrink: 0;
}

.period-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.period-tag-name {
    font-size: 13px;
    font-weight: bold;
    color: var(--text-sidebar);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.period-dates {
    font-size: 11px;
    color: var(--text-light);
}

.period-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: 8px;
}

.period-edit,
.period-delete {
    background: transparent;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    width: auto;
    min-width: 28px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    transition: background 0.2s;
}

.period-edit:hover {
    background: rgba(99, 102, 241, 0.3);
}

.period-delete:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-sidebar);
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    color: var(--text-sidebar);
    box-shadow: 0 10px 30px var(--shadow-color);
    transition: background-color 0.3s ease;
}

.modal-content h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 10px;
}

.modal-form label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: var(--text-sidebar);
}

.modal-form select,
.modal-form input[type="date"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
}

/* Date Selection */
.date-selection {
    margin-bottom: 15px;
    padding: 10px;
    background: var(--bg-date-selection);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

/* Calendar Container */
.calendar-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    position: relative;
    background: var(--bg-primary);
    transition: background-color 0.3s ease;
}

#calendar {
    width: 100%;
}

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

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 50vh;
    }
    
    .calendar-container {
        height: 50vh;
    }
}

/* Leyenda para impresión */
.print-legend {
    display: none;
}

.print-legend h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
    border-bottom: 2px solid #333;
    padding-bottom: 5px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    margin-right: 20px;
    margin-bottom: 8px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    margin-right: 8px;
    border: 1px solid #ccc;
}

.legend-name {
    font-size: 14px;
    color: #333;
}

/* Estilos de impresión */
@media print {
    /* Forzar tema claro para impresión */
    :root {
        --bg-primary: #f5f5f5;
        --bg-secondary: #ffffff;
        --bg-sidebar: #2c3e50;
        --bg-sidebar-item: #34495e;
        --bg-input: #ffffff;
        --bg-date-selection: #34495e;
        
        --text-primary: #333333;
        --text-secondary: #666666;
        --text-sidebar: #ecf0f1;
        --text-muted: #95a5a6;
        --text-light: #bdc3c7;
        
        --accent-primary: #3498db;
        --accent-primary-hover: #2980b9;
        --accent-secondary: #95a5a6;
        --accent-secondary-hover: #7f8c8d;
        --accent-danger: #e74c3c;
        --accent-danger-hover: #c0392b;
        
        --border-color: #ddd;
        --shadow-color: rgba(0, 0, 0, 0.1);
        --modal-overlay: rgba(0, 0, 0, 0.6);
    }
    
    body {
        background: white;
        overflow: visible;
        height: auto;
        color: #333333;
    }
    
    .container {
        display: block;
        height: auto;
        overflow: visible;
    }
    
    .sidebar {
        display: none !important;
    }
    
    .calendar-container {
        width: 100%;
        height: auto !important;
        overflow: visible;
        padding: 0;
    }
    
    #calendar {
        width: 100%;
        height: auto !important;
        min-height: auto !important;
    }
    
    .print-legend {
        display: block;
        margin-top: 20px;
        padding: 15px;
        border-top: 2px solid #333;
        page-break-inside: avoid;
    }
    
    #legendContent {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .print-footer {
        display: block !important;
        margin-top: 30px;
        padding-top: 15px;
        border-top: 1px solid #ccc;
        text-align: center;
        font-size: 16px;
        color: #666;
        page-break-inside: avoid;
    }
    
    .print-footer a {
        color: #3498db;
        text-decoration: none;
    }
}

/* Ocultar pie de página en pantalla */
.print-footer {
    display: none;
}

/* Mensaje vacío */
.empty-message {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}
