:root {
    --color-pill-pink: #ff8fa3;
    --color-pill-pink-border: #ff758f;
    --color-pill-blue: #38bdf8;
    --color-pill-blue-border: #0ea5e9;
    --color-pill-orange: #fb923c;
    --color-pill-orange-border: #f97316;
}

/* 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, var(--color-pill-pink));
    border: 1px solid var(--color-pill-pink-border);
}

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

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

.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: 5mm 8mm;
    }

    * {
        -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 !important;
        margin: 0 !important;
        font-size: 11pt;
        line-height: 1.3;
        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: 18pt;
        font-weight: 900;
        text-align: center;
        margin-bottom: 2mm;
    }

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

    .print-footer-note {
        font-size: 9pt;
        text-align: center;
        margin-top: 3mm;
        font-style: italic;
        color: #555;
        border-top: 1px solid #ddd;
        padding-top: 2mm;
    }

    .print-row {
        display: flex;
        align-items: center;
        gap: 20px;
        padding: 8px 15px;
        border-bottom: 1px solid #ccc;
        font-size: 16pt;
    }

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

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

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

    #print-instructions {
        margin-top: 10px;
        padding: 10px;
        border: 1px solid #eee;
        border-radius: 12px;
        font-size: 12pt;
        line-height: 1.4;
    }
}

.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 - transparent overlay behind custom span display */
#appt-date-picker {
    appearance: none;
    -webkit-appearance: none;
    opacity: 0 !important;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    z-index: 10;
}

/* 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;
}

.app-footer-info {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 24px auto 0;
}

.usage-counter,
.facebook-contact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: fit-content;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    color: #334155;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.facebook-contact {
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    color: #1d4ed8;
    transition: all 0.2s;
}

.facebook-contact:hover {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1e40af;
}

.usage-counter-icon,
.facebook-contact-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: #0f766e;
    color: #ffffff;
}

.facebook-contact-icon {
    background: #1877f2;
}

.usage-counter-content {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.usage-counter-label {
    font-size: 13px;
    font-weight: 800;
    color: #475569;
}

.usage-counter-value {
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
    color: #0f766e;
}

.usage-counter-offline {
    opacity: 0.55;
}

.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 - transparent overlay, display handled by custom span */
#appt-date-picker {
    appearance: none;
    -webkit-appearance: none;
    opacity: 0 !important;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    z-index: 10;
}

/* 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;
}

/* ==========================================================================
   Monthly Calendar Styles
   ========================================================================== */

.calendar-container {
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.calendar-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendar-month-title {
    font-size: 15px;
    font-weight: 800;
    color: #1e293b;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-grid-header {
    text-align: center;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.calendar-grid-header:first-child {
    color: #ef4444; /* Sunday */
}
.calendar-grid-header:last-child {
    color: #a855f7; /* Saturday */
}

.calendar-day-cell {
    min-height: 85px;
    padding: 6px 4px;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: white;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-day-cell:nth-child(7n) {
    border-right: none;
}

.calendar-day-cell:hover {
    background: #f8fafc;
    transform: scale(1.01);
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.calendar-day-cell.outside-range {
    background: #f8fafc;
    opacity: 0.35;
    cursor: pointer;
}

.calendar-day-cell.weekend-cell {
    background: #fef2f2;
}

.calendar-day-cell.weekend-cell:hover {
    background: #fee2e2;
}

.calendar-day-cell.weekend-cell.outside-range {
    background: #faf5f5;
}

.calendar-day-cell.day-hold {
    background: #fff5f5;
}

.calendar-day-cell.day-hold:hover {
    background: #fee2e2;
}

.calendar-day-cell.day-checked {
    background: #f1f5f9 !important;
}

.calendar-day-cell.day-checked .day-number {
    color: #94a3b8;
    text-decoration: line-through;
}

.calendar-day-cell.day-checked .day-dose-text {
    color: #94a3b8 !important;
    text-decoration: line-through;
}

.calendar-day-cell.day-checked .pill-mini {
    opacity: 0.35;
    filter: grayscale(80%);
}

.calendar-day-cell.day-checked::after {
    content: '\f058'; /* FontAwesome checked circle */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 6px;
    right: 6px;
    color: #10b981;
    font-size: 14px;
}

.calendar-day-cell.day-appt {
    border: 2px solid #ef4444 !important;
    background: #fef2f2;
}

.calendar-day-cell.day-appt:hover {
    background: #fee2e2;
}

.day-number {
    font-size: 13px;
    font-weight: 800;
    color: #334155;
}

.day-dose-text {
    font-size: 10px;
    font-weight: 900;
    margin-top: 4px;
    white-space: nowrap !important;
}

.day-dose-text.dose-long {
    font-size: 8.5px !important;
    letter-spacing: -0.03em;
}

.calendar-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    justify-content: center;
}

.day-checkbox-indicator {
    width: 12px;
    height: 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 50%;
    margin-top: 4px;
    display: inline-block;
    transition: all 0.2s;
}

.calendar-day-cell:hover .day-checkbox-indicator {
    border-color: #3b82f6;
}

.calendar-day-cell.day-checked .day-checkbox-indicator {
    display: none;
}

/* Miniature Pills */
.pill-mini {
    width: 28px;
    height: 28px;
    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-mini::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: rgba(0, 0, 0, 0.08);
}

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

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

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

.pill-mini.half-pill-mini {
    width: 14px;
    border-radius: 28px 0 0 28px;
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.2), 2px 2px 4px rgba(0, 0, 0, 0.05);
}

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

/* Print Calendar Area Styling */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body.printing-calendar #print-weekly-area {
        display: none !important;
    }
    
    body.printing-calendar #print-calendar-area {
        display: block !important;
    }

    .print-calendar-title {
        font-size: 20pt;
        font-weight: 900;
        text-align: center;
        margin-bottom: 2mm;
    }
    
    .print-calendar-month {
        page-break-inside: avoid;
        margin-bottom: 8mm;
    }

    .print-calendar-month-title {
        font-size: 14pt;
        font-weight: 900;
        margin-bottom: 3mm;
        text-align: center;
        background: #e2e8f0 !important;
        padding: 8px;
        border-radius: 6px;
        border: 1px solid #cbd5e1;
    }

    .print-calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        border-top: 1.5px solid #000;
        border-left: 1.5px solid #000;
    }

    .print-calendar-header-cell {
        text-align: center;
        padding: 8px 4px;
        font-size: 11pt;
        font-weight: 900;
        border-right: 1.5px solid #000;
        border-bottom: 1.5px solid #000;
    }

    .print-calendar-day-cell {
        min-height: 28mm;
        padding: 6px 4px;
        border-right: 1.5px solid #000;
        border-bottom: 1.5px solid #000;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        background: white;
    }

    .print-calendar-day-cell.outside-range {
        background: #f1f5f9 !important;
        opacity: 0.3;
    }

    .print-calendar-day-cell.weekend-cell {
        background: #fef2f2 !important;
    }

    .print-calendar-day-cell.weekend-cell.outside-range {
        background: #faf5f5 !important;
    }

    .print-calendar-day-cell.day-hold {
        background: #fee2e2 !important;
    }

    .print-calendar-day-cell.day-appt {
        border: 3px solid #ef4444 !important;
        background: #fef2f2 !important;
    }
    
    .print-calendar-day-cell .day-number {
        font-size: 12pt;
        font-weight: 900;
    }
    
    .print-calendar-day-cell .day-dose-text {
        font-size: 8pt !important;
        font-weight: 900;
        white-space: nowrap !important;
    }
    
    .print-calendar-day-cell .day-dose-text.dose-long {
        font-size: 7.2pt !important;
        letter-spacing: -0.03em;
    }
    
    .print-calendar-day-cell .pill-mini {
        width: 34px;
        height: 34px;
        box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.2), 2px 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .print-calendar-day-cell .pill-mini.half-pill-mini {
        width: 17px;
        border-radius: 34px 0 0 34px;
    }

    .print-calendar-day-cell .calendar-pills {
        gap: 8px !important;
    }
}
