/**
 * =================================================================
 * COMPONENTS CSS - CALENDARI IOC
 * =================================================================
 * 
 * @file        components.css
 * @description Estils per components UI (capçalera, sidebar, panells, botons)
 * @author      Ismael Trascastro <itrascastro@ioc.cat>
 * @version     1.0
 * @date        2025-01-16
 * @project     Calendari IOC
 * @repository  https://github.com/itrascastro/calendari-ioc
 * @license     MIT
 * 
 * Aquest fitxer forma part del projecte Calendari IOC,
 * una aplicació web per gestionar calendaris acadèmics.
 * 
 * =================================================================
 */

/* === CAPÇALERA PRINCIPAL === */
.main-header { 
    grid-area: header; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 10px 20px; 
    background-color: var(--card-bg-color); 
    border: 1px solid var(--border-color); 
    border-radius: 10px; 
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03); 
}

.header-title { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

.header-logo { 
    height: 56px; 
    width: auto; 
}



.main-header h1 { 
    font-size: 1.5em; 
    color: var(--accent-color); 
    margin: 0; 
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-button { 
    padding: 8px 16px; 
    font-size: 0.9em; 
    cursor: pointer; 
    border: 1px solid var(--border-color); 
    background-color: transparent; 
    color: var(--main-text-color); 
    border-radius: 20px; 
    transition: background-color 0.2s, color 0.2s; 
}

.header-button:hover { 
    background-color: #e9ecef; 
}

/* === SIDEBAR === */
.sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-right: 4px;
    min-height: 0;
    overflow-y: auto;
}

/* === PANELLS === */
.panel-scrollable {
    flex-grow: 1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 400px;
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
}

.panel-content {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
}

.panel-header,
.sidebar-actions,
.panel-footer {
    flex-shrink: 0;
}

.panel-header {
    font-size: 1.1em;
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--accent-color);
}

/* === BOTONS D'ACCIÓ === */
.sidebar-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.action-btn {
    flex: 1;
    padding: 10px;
    font-weight: 500;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--main-text-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* === LLISTA DE CALENDARIS === */
.calendar-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    min-height: 38px;
    padding: 5px;
    border-radius: 6px;
    margin-bottom: 8px;
    margin-right: 8px;
    cursor: pointer;
}

.calendar-list-item:hover {
    background-color: #f8f9fa;
}

.calendar-list-item.active {
    background-color: #e9ecef;
}

.calendar-info {
    flex-grow: 1;
}

.calendar-name {
    font-weight: 600;
    color: var(--main-text-color);
    line-height: 1.3;
}

.calendar-dates {
    font-size: 0.8em;
    color: var(--secondary-text-color);
    margin-top: 2px;
}

.calendar-list-item .actions-menu {
    background: none;
    border: none;
    color: var(--secondary-text-color);
    cursor: pointer;
    font-size: 1.2em;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.calendar-list-item .actions-menu:hover {
    color: var(--main-text-color);
}

/* === MODALS D'ACCIONS === */
.calendar-actions-modal {
    background-color: transparent !important;
    backdrop-filter: none !important;
    pointer-events: none;
}

.color-picker-modal {
    background-color: transparent !important;
    backdrop-filter: none !important;
    pointer-events: none;
}

.calendar-actions-content {
    position: absolute;
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    width: auto;
    min-width: fit-content;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    pointer-events: auto;
}

.calendar-actions-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: auto;
    min-width: fit-content;
}

.calendar-action-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--main-text-color);
    font-size: 0.9em;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.calendar-action-btn:last-child {
    border-bottom: none;
}

.calendar-action-btn:hover {
    background-color: var(--bg-color);
}

.calendar-action-btn.danger {
    color: var(--danger-color);
}

.calendar-action-btn.danger:hover {
    background-color: var(--danger-color);
    color: white;
}

/* === SELECTOR DE COLORS === */
.color-picker-content {
    position: absolute;
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 8px;
    pointer-events: auto;
}

.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    width: 310px;
}

.color-option {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: var(--main-text-color);
}

.color-option.selected {
    border-color: var(--accent-color);
    transform: scale(1.2);
}

/* === MENÚ CONTEXTUAL === */
.actions { 
    position: relative; 
}

.actions-dropdown { 
    position: absolute; 
    right: 0; 
    top: 100%; 
    background-color: var(--card-bg-color); 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); 
    z-index: 1000; 
    min-width: 140px; 
    opacity: 0; 
    visibility: hidden; 
    transform: translateY(-5px); 
    transition: all 0.2s ease; 
}

.actions-dropdown.show { 
    opacity: 1; 
    visibility: visible; 
    transform: translateY(0); 
}

.actions-dropdown-item { 
    padding: 10px 16px; 
    cursor: pointer; 
    transition: background-color 0.2s; 
    color: var(--main-text-color); 
    font-size: 0.9em; 
    border-bottom: 1px solid var(--border-color); 
}

.actions-dropdown-item:last-child { 
    border-bottom: none; 
}

.actions-dropdown-item:hover { 
    background-color: var(--bg-color); 
}

.actions-dropdown-item.danger { 
    color: var(--danger-color); 
}

.actions-dropdown-item.danger:hover { 
    background-color: var(--danger-color); 
    color: white; 
}

.actions-dropdown-item.disabled { 
    color: var(--secondary-text-color); 
    cursor: not-allowed; 
    opacity: 0.6; 
}

.actions-dropdown-item.disabled:hover { 
    background-color: transparent; 
}

/* === LLISTA DE CATEGORIES === */
.category-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    min-height: 38px;
    padding: 5px;
    border-radius: 6px;
    margin-bottom: 8px;
    margin-right: 8px;
}

.category-list-item:hover {
    background-color: #f8f9fa;
}

.category-list-item.active {
    background-color: #e9ecef;
}

.color-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-dot:hover {
    transform: scale(1.1);
}

.category-name-wrapper {
    flex-grow: 1;
}

.category-name {
    padding: 5px;
    line-height: 1.5;
}

.delete-icon {
    background-color: var(--danger-color);
    color: white;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    line-height: 22px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.category-list-item:hover .delete-icon {
    opacity: 1;
}

.category-list-item .delete-icon {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
}

.category-list-item .delete-icon:hover {
    background-color: var(--danger-hover);
}

.actions-menu {
    font-weight: bold;
    font-size: 1.2em;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--secondary-text-color);
    transition: all 0.2s;
}

.actions-menu:hover {
    background-color: var(--bg-color);
    color: var(--main-text-color);
}

/* === FORMULARI NOVA CATEGORIA === */
.new-category-form {
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
    padding-top: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 38px;
}

.category-input {
    flex-grow: 1;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: #f8f9fa;
    margin-right: 8px;
    font-size: 0.9em;
}

.new-category-form .category-input {
    margin-right: 12px;
}

.btn-add-category {
    background-color: var(--accent-color);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.5em;
    line-height: 28px;
    text-align: center;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.btn-add-category:hover {
    background-color: var(--accent-hover);
}

/* === ESDEVENIMENTS NO UBICATS === */
.unplaced-event-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 8px;
    margin-right: 8px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    cursor: grab;
    transition: all 0.2s ease;
}

.unplaced-event-item:hover {
    background-color: var(--card-bg-color);
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.unplaced-event-item:first-child {
    margin-top: 12px;
}

.unplaced-event-item[draggable="true"]:active {
    cursor: grabbing;
    opacity: 0.8;
}

.unplaced-event-content {
    flex-grow: 1;
    display: block;
}

.unplaced-event-item .event-title {
    font-weight: 600;
    color: var(--main-text-color);
    font-size: 0.9em;
    line-height: 1.4;
    margin-bottom: 4px;
    display: block;
    width: 100%;
}

.unplaced-event-item .event-category {
    font-size: 0.8em;
    color: var(--accent-color);
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 4px;
    display: block;
    width: 100%;
}

.unplaced-event-item .event-original-date {
    font-size: 0.8em;
    color: var(--secondary-text-color);
    font-weight: 500;
    line-height: 1.4;
    display: block;
    width: 100%;
}