.calendar-page {
    max-width: var(--small-width);
    margin: 0 auto;
    padding: 30px;
}

.calendar-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
}

.calendar-config {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    height: fit-content;
}

.config-section {
    margin-bottom: 24px;
}

.config-section:last-child {
    margin-bottom: 0;
}

.config-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-section-title::before {
    content: '📝';
    font-size: 18px;
}

.config-label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 12px;
    display: block;
}

.template-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.template-option {
    padding: 10px 14px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    transition: all 0.3s ease;
    background: #ffffff;
}

.template-option:hover {
    background: #f8fafc;
}

.template-option.active {
    border-color: #ec4899;
    background: #fef2f7;
}

.template-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.template-option:nth-child(1) .template-icon {
    background-color: #ec4899;
}

.template-option:nth-child(2) .template-icon {
    background-color: #22c55e;
}

.template-option:nth-child(3) .template-icon {
    background-color: #f59e0b;
}

.template-option:nth-child(4) .template-icon {
    background-color: #8b5cf6;
}

.input-field label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
    display: block;
}

.input-field input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    font-size: 14px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.input-field input:focus {
    outline: none;
    border-color: #ec4899;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.reset-btn {
    flex: 1;
    padding: 8px 16px;
    border-radius: 10px;
    background: #f1f5f9;
    color: #475569;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.print-btn {
    flex: 1;
    padding: 8px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.print-btn:hover {
    box-shadow: 0 6px 16px rgba(236, 72, 153, 0.4);
}

.calendar-preview {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow: hidden;
    min-height: 400px;
}

.preview-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    padding-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 10px;
}

.preview-title {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    gap: 8px;
}

.preview-title::before {
    content: '👁️';
    font-size: 18px;
}

.calendar-output {
    background: #fff;
    border-radius: 0;
    padding: 16px;
    margin: 0;
    border: none;
    overflow: hidden;
    box-sizing: border-box;
}

.calendar-title {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: #ec4899;
    margin-bottom: 10px;
    letter-spacing: 3px;
    line-height: 2;
}

.calendar-table {
    width: 100%;
    overflow-x: auto;
}

.calendar-table table {
    height: 100%;
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.calendar-table th {
    padding: 2px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    border: 1px solid #fbcfe8;
    white-space: nowrap;
    background: #fce7f3;
    color: #ec4899;
}

.calendar-table th.col-week {
    width: 10%;
}

.calendar-table th.col-day {
    width: 9%;
}

.calendar-table th.col-weekend {
    background: #fbcfe8;
}

.calendar-table th.col-note {
    width: 20%;
}

.calendar-table td {
    padding: 1px;
    font-size: 14px;
    text-align: center;
    border: 1px solid #fbcfe8;
    vertical-align: middle;
    height: auto;
    box-sizing: border-box;
}

.week-row {
    height: auto;
}

.calendar-table thead th {
    height: 10mm;
}

.calendar-table td.col-week {
    width: 10%;
    letter-spacing: 2px;
}

.calendar-table td.col-day {
    width: 9%;
}

.calendar-table td.col-note {
    width: 20%;
}

.week-cell {
    font-weight: 500;
    color: #6b7280;
}

.day-cell {
    position: relative;
    min-height: 30px;
}

.day-cell.out-of-range {
    background: transparent;
    border-color: transparent;
}

.day-cell.weekend {
    background: #fce7f3;
}

.day-cell.holiday {
    background: #fee2e2;
}

.day-number {
    font-weight: 500;
    color: #374151;
}

.holiday-tag {
    display: block;
    font-size: 12px;
    color: #ef4444;
}

.note-cell {
    background: #fff1f2;
}

.calendar-output.template-style1 { border-color: #fbcfe8; }
.calendar-output.template-style1 .calendar-title { color: #ec4899; }
.calendar-output.template-style1 .calendar-table th { background: #fce7f3; color: #ec4899; border-color: #fbcfe8; }
.calendar-output.template-style1 .calendar-table th.col-weekend { background: #fbcfe8; }
.calendar-output.template-style1 .calendar-table td { border-color: #fbcfe8; }
.calendar-output.template-style1 .day-cell.weekend { background: #fce7f3; }
.calendar-output.template-style1 .day-cell.holiday { background: #fee2e2; }
.calendar-output.template-style1 .holiday-tag { color: #ef4444; }
.calendar-output.template-style1 .note-cell { background: #fff1f2; }

.calendar-output.template-style2 { border-color: #dcfce7; }
.calendar-output.template-style2 .calendar-title { color: #22c55e; }
.calendar-output.template-style2 .calendar-table th { background: #dcfce7; color: #22c55e; border-color: #bbf7d0; }
.calendar-output.template-style2 .calendar-table th.col-weekend { background: #bbf7d0; }
.calendar-output.template-style2 .calendar-table td { border-color: #bbf7d0; }
.calendar-output.template-style2 .day-cell.weekend { background: #dcfce7; }
.calendar-output.template-style2 .day-cell.holiday { background: #d1fae5; }
.calendar-output.template-style2 .holiday-tag { color: #16a34a; }
.calendar-output.template-style2 .note-cell { background: #f0fdf4; }

.calendar-output.template-style3 { border-color: #fef3c7; }
.calendar-output.template-style3 .calendar-title { color: #f59e0b; }
.calendar-output.template-style3 .calendar-table th { background: #fef3c7; color: #f59e0b; border-color: #fde68a; }
.calendar-output.template-style3 .calendar-table th.col-weekend { background: #fde68a; }
.calendar-output.template-style3 .calendar-table td { border-color: #fde68a; }
.calendar-output.template-style3 .day-cell.weekend { background: #fef3c7; }
.calendar-output.template-style3 .day-cell.holiday { background: #fed7aa; }
.calendar-output.template-style3 .holiday-tag { color: #dc2626; }
.calendar-output.template-style3 .note-cell { background: #fffbeb; }

.calendar-output.template-style4 { border-color: #ede9fe; }
.calendar-output.template-style4 .calendar-title { color: #8b5cf6; }
.calendar-output.template-style4 .calendar-table th { background: #ede9fe; color: #8b5cf6; border-color: #ddd6fe; }
.calendar-output.template-style4 .calendar-table th.col-weekend { background: #ddd6fe; }
.calendar-output.template-style4 .calendar-table td { border-color: #ddd6fe; }
.calendar-output.template-style4 .day-cell.weekend { background: #ede9fe; }
.calendar-output.template-style4 .day-cell.holiday { background: #ddd6fe; }
.calendar-output.template-style4 .holiday-tag { color: #ef4444; }
.calendar-output.template-style4 .note-cell { background: #faf5ff; }

@page {
    size: A4 portrait;
    margin: 0;
}

@page :first {
    margin: 0;
}

@media print {
    * {
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        visibility: hidden !important;
    }

    body {
        visibility: visible !important;
        background: #fff !important;
        width: 210mm !important;
        height: 297mm !important;
    }

    #calendarOutput {
        visibility: visible !important;
        background: #fff !important;
        padding: 2cm !important;
        margin: 0 !important;
        width: 210mm !important;
        height: 297mm !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        box-sizing: border-box !important;
        page-break-inside: avoid !important;
    }

    #calendarOutput * {
        visibility: visible !important;
    }

    #calendarOutput .calendar-title {
        text-align: center;
        font-size: 24px;
        font-weight: 700;
        color: #ec4899;
        margin-bottom: 10px;
        letter-spacing: 3px;
        line-height: 2;
    }

    #calendarOutput .calendar-table th {
        padding: 2px;
        font-size: 14px;
        font-weight: 600;
        height: 10mm;
    }

    #calendarOutput .calendar-table td {
        padding: 1px;
        font-size: 14px;
        height: auto;
    }

    #calendarOutput .calendar-table th.col-week,
    #calendarOutput .calendar-table td.col-week {
        width: 10%;
    }

    #calendarOutput .calendar-table th.col-day,
    #calendarOutput .calendar-table td.col-day {
        width: 9%;
    }

    #calendarOutput .calendar-table th.col-note,
    #calendarOutput .calendar-table td.col-note {
        width: 20%;
    }

    #calendarOutput .day-cell {
        min-height: 30px;
    }

    #calendarOutput .holiday-tag {
        font-size: 12px;
    }
}

@media (max-width: 1024px) {
    .calendar-container {
        grid-template-columns: 1fr;
    }

    .calendar-config {
        order: 2;
    }

    .calendar-preview {
        order: 1;
    }
}

@media (max-width: 768px) {
    .calendar-page {
        padding: 16px;
    }

    .template-selector {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .template-selector {
        grid-template-columns: 1fr;
    }

    .calendar-output {
        padding: 10px;
    }

    .calendar-title {
        font-size: 14px;
    }

    .calendar-table th,
    .calendar-table td {
        padding: 4px 2px;
        font-size: 9px;
    }

    .day-cell {
        min-height: 25px;
    }
}