/* === Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #0f1117;
    color: #e5e7eb;
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* === Header === */
.cal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.month-title {
    font-size: 1.5rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.nav-btn, .today-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border: 1px solid #374151;
    border-radius: 6px;
    background: #1f2937;
    color: #d1d5db;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.nav-btn:hover, .today-btn:hover {
    background: #374151;
}

/* === Legend === */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 8px;
}

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

.legend-user {
    font-weight: 600;
    font-size: 0.8rem;
    color: #9ca3af;
}

.legend-chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

/* === Input Section === */
.input-section {
    margin-bottom: 16px;
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row select {
    padding: 8px 12px;
    border: 1px solid #374151;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #1f2937;
    color: #e5e7eb;
    min-width: 160px;
}

.input-row input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #374151;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #1f2937;
    color: #e5e7eb;
}

.input-row input[type="text"]::placeholder {
    color: #6b7280;
}

.input-row input[type="text"]:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.input-row button {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    background: #4f46e5;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.input-row button:hover { background: #4338ca; }
.input-row button:disabled { background: #374151; color: #6b7280; cursor: not-allowed; }

.parse-status {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #1e3a5f;
    color: #93c5fd;
}

.parse-status.parse-error {
    background: #3b1111;
    color: #fca5a5;
}

.confirm-card {
    margin-top: 8px;
    padding: 12px 16px;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.confirm-content {
    font-size: 0.9rem;
}

.confirm-buttons {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-confirm {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    background: #059669;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-confirm:hover { background: #047857; }

.btn-confirm.btn-secondary {
    background: #4b5563;
}

.btn-confirm.btn-secondary:hover { background: #374151; }

.btn-cancel {
    padding: 6px 16px;
    border: 1px solid #374151;
    border-radius: 6px;
    background: #1f2937;
    color: #d1d5db;
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-cancel:hover { background: #374151; }

/* === Edit Panel === */
.edit-panel {
    margin-bottom: 16px;
    padding: 16px;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.edit-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.edit-panel-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.edit-panel-body label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    font-weight: 500;
    color: #9ca3af;
    gap: 4px;
}

.edit-panel-body select,
.edit-panel-body input {
    padding: 6px 10px;
    border: 1px solid #374151;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #111827;
    color: #e5e7eb;
}

.edit-panel-actions {
    display: flex;
    gap: 8px;
}

.btn-delete {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    background: #dc2626;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-delete:hover { background: #b91c1c; }

/* === Calendar Grid === */
.cal-grid {
    width: 100%;
    border-collapse: collapse;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed;
}

.cal-grid th {
    padding: 8px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    background: #111827;
    border-bottom: 1px solid #374151;
    text-align: center;
}

.cal-cell {
    border: 1px solid #374151;
    vertical-align: top;
    padding: 4px;
    min-height: 90px;
    height: 90px;
    position: relative;
    background: #28303d;
}

.cal-cell:hover {
    background: #243044;
}

.cal-cell.weekend {
    background: #2a323f;
}

.cal-cell.out-of-month {
    background: #0f1117;
}

.cal-cell.out-of-month .day-number {
    color: #374151;
}

.cal-cell.today {
    background: #292407;
}

.day-number {
    font-size: 0.8rem;
    font-weight: 500;
    color: #d1d5db;
    margin-bottom: 2px;
}

/* === Bars === */
.bars {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bar {
    height: 22px;
    display: flex;
    align-items: center;
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.bar:hover {
    opacity: 0.85;
}

.bar-highlight {
    opacity: 0.85;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.bar-start {
    border-radius: 4px 0 0 4px;
    margin-left: 2px;
}

.bar-end {
    border-radius: 0 4px 4px 0;
    margin-right: 2px;
}

.bar-single {
    border-radius: 4px;
    margin-left: 2px;
    margin-right: 2px;
}

.bar-middle {
    border-radius: 0;
}

.bar-text {
    font-size: 0.65rem;
    font-weight: 700;
    padding-left: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Print === */
@media print {
    body { background: #fff; color: #1a1a1a; }
    .cal-header .nav-btn,
    .cal-header .today-btn,
    .input-section,
    .edit-panel { display: none !important; }

    .container { max-width: 100%; padding: 0; }

    @page { size: landscape; margin: 0.5in; }

    .bar, .legend-chip {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .cal-cell { min-height: 70px; height: auto; }
    .cal-cell:hover { background: transparent; }

    .cal-grid { background: #fff; border-color: #e5e7eb; }
    .cal-grid th { background: #f9fafb; color: #6b7280; border-color: #e5e7eb; }
    .cal-cell { border-color: #e5e7eb; }
    .legend { background: #fff; border-color: #e5e7eb; }
}

/* === Responsive === */
@media (max-width: 768px) {
    .cal-cell { min-height: 60px; height: 60px; padding: 2px; }
    .day-number { font-size: 0.7rem; }
    .bar { height: 18px; }
    .bar-text { display: none; }
    .month-title { font-size: 1.1rem; }
    .legend { font-size: 0.75rem; }

    /* Header: tighten gap so month title has more room */
    .cal-header { gap: 6px; margin-bottom: 10px; }

    /* Dropdown: shrink to just fit TML/HMB */
    .input-row select { min-width: 0; width: auto; padding: 8px 6px; }
}
