/* Core */
body {
    font-family: 'Sarabun', sans-serif;
    background-color: #f8fafc;
}

/* Pill Rendering (Realistic) */
.pill-render {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    position: relative;
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.2), 2px 2px 4px rgba(0, 0, 0, 0.1);
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.pill-render::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
    box-shadow: 1px 0 0 rgba(255, 255, 255, 0.2);
}

.pill-pink {
    background: radial-gradient(circle at 30% 30%, #ffcbd1, #ff8fa3);
    border: 1px solid #ff758f;
}

.pill-blue {
    background: radial-gradient(circle at 30% 30%, #bae6fd, #38bdf8);
    border: 1px solid #0ea5e9;
}

.pill-orange {
    background: radial-gradient(circle at 30% 30%, #fed7aa, #fb923c);
    border: 1px solid #f97316;
}

.half-pill {
    width: 16px;
    border-radius: 32px 0 0 32px;
    overflow: hidden;
}

.half-pill::after {
    display: none;
}

/* Interactive Controls */
input[type=range] {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    appearance: none;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    border: 2px solid white;
}

/* Print Layout (A4 Optimized, COLOR) */
@media print {
    @page {
        size: A4 portrait;
        margin: 8mm 10mm;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    body {
        background: white;
        padding: 0;
        margin: 0;
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
    }

    .main-container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #print-schedule {
        page-break-inside: avoid;
    }

    .print-header {
        font-size: 22pt;
        font-weight: 900;
        text-align: center;
        margin-bottom: 5mm;
    }

    .print-subheader {
        font-size: 14pt;
        text-align: center;
        color: #444;
        margin-bottom: 5mm;
    }

    .print-footer-note {
        font-size: 10pt;
        text-align: center;
        margin-top: 5mm;
        font-style: italic;
        color: #666;
        border-top: 1px solid #ccc;
        padding-top: 3mm;
    }

    .print-row {
        display: flex;
        align-items: center;
        gap: 30px;
        padding: 22px 15px;
        border-bottom: 2px solid #bbb;
        font-size: 16pt;
    }

    .print-day {
        font-weight: 900;
        min-width: 120px;
        font-size: 20pt;
    }

    .print-instr {
        flex: 1;
        font-weight: 700;
        line-height: 2.0;
    }

    .print-time {
        font-weight: 700;
        color: #b45309;
        font-size: 10pt;
        white-space: nowrap;
    }

    #print-instructions {
        margin-top: 20px;
        padding: 15px;
        border: 2px solid #eee;
        border-radius: 12px;
        font-size: 14pt;
        line-height: 1.8;
    }
}

.print-only {
    display: none;
}

/* Screen-only print row styling (mirrored for dev) */
.print-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-bottom: 1px solid #e2e8f0;
}

.print-day {
    font-weight: 900;
    min-width: 70px;
}

.print-instr {
    flex: 1;
    font-weight: 600;
}

.print-time {
    font-weight: 700;
    color: #b45309;
    white-space: nowrap;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Alt Regimen Section */
.alt-regimen-section {
    animation: slideDown 0.3s ease-out;
}

.alt-regimen-section.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alt-toggle-icon {
    transition: transform 0.25s ease;
}

.alt-toggle-icon.rotated {
    transform: rotate(180deg);
}

/* Regimen Card */
.regimen-card {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.regimen-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.regimen-card:active {
    transform: translateY(0);
}

.regimen-card.type-uniform {
    border-left: 5px solid #10b981;
}

.regimen-card.type-special {
    border-left: 5px solid #3b82f6;
}

.regimen-card.type-stop {
    border-left: 5px solid #ef4444;
}

.regimen-card .card-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.regimen-card.type-uniform .card-badge {
    background: #d1fae5;
    color: #065f46;
}

.regimen-card.type-special .card-badge {
    background: #dbeafe;
    color: #1e40af;
}

.regimen-card.type-stop .card-badge {
    background: #fee2e2;
    color: #991b1b;
}

.regimen-schedule-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 10px;
}

.regimen-day-cell {
    text-align: center;
    padding: 6px 2px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.regimen-day-cell .day-label {
    font-size: 10px;
    font-weight: 800;
    color: #64748b;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.regimen-day-cell .day-dose {
    font-size: 16px;
    font-weight: 900;
}

.regimen-day-cell.dose-normal {
    background: #f0f9ff;
}

.regimen-day-cell.dose-normal .day-dose {
    color: #0369a1;
}

.regimen-day-cell.dose-special {
    background: #fef3c7;
}

.regimen-day-cell.dose-special .day-dose {
    color: #b45309;
}

.regimen-day-cell.dose-stop {
    background: #fee2e2;
}

.regimen-day-cell.dose-stop .day-dose {
    color: #dc2626;
}

.alt-copy-btn:hover {
    background: #e2e8f0 !important;
    color: #334155 !important;
}

.alt-print-btn:hover {
    background: #dbeafe !important;
    color: #2563eb !important;
}

.alt-copy-btn:active, .alt-print-btn:active {
    transform: scale(0.96);
}

.regimen-no-result {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}

.regimen-no-result i {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
    color: #cbd5e1;
}

/* Scrollbar tweaks */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Modal Styles */
#calc-modal.hidden {
    display: none !important;
    opacity: 0;
}

#calc-modal {
    transition: opacity 0.3s ease;
}

.animate-slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.alt-calc-pill-btn {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.alt-calc-pill-btn:hover {
    background: #dcfce7;
    border-color: #4ade80;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.15);
}

.alt-calc-pill-btn:active {
    transform: translateY(0);
}

/* Custom Date Picker & Compact Styles */
#appt-date-picker {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    border: 1px solid #e2e8f0;
    padding-left: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 6px center;
    background-size: 13px;
    height: 24px;
    line-height: normal;
}

#appt-date-picker:hover {
    border-color: #3b82f6;
    background-color: #f0f7ff;
}

#appt-date-picker:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
    background-color: #fff;
}

/* Hide default calendar icon */
#appt-date-picker::-webkit-calendar-picker-indicator {
    opacity: 0;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.active-day {
    background: #2563eb !important;
    color: white !important;
    border-color: #2563eb !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

/* Custom Date Picker Styling */
#appt-date-picker {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    border: 1px solid #e2e8f0;
    padding-left: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 8px center;
    background-size: 14px;
}

#appt-date-picker:hover {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

#appt-date-picker:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background-color: #fff;
}

/* Hide default calendar icon in some browsers to use ours */
#appt-date-picker::-webkit-calendar-picker-indicator {
    opacity: 0;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}