/* ==========================================
   PillUp Premium Design System & Stylesheet
   ========================================== */

/* Variables & Base System */
:root {
    --bg-main: #0b0f19;
    --bg-sidebar: #101626;
    --bg-card: rgba(22, 30, 49, 0.45);
    --bg-card-hover: rgba(28, 38, 62, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(124, 58, 237, 0.4);

    --primary: #8b5cf6;       /* Radiant Violet */
    --primary-glow: rgba(139, 92, 246, 0.15);
    --success: #10b981;       /* Electric Green */
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;       /* Warm Amber (Streak) */
    --danger: #ef4444;        /* Soft Crimson */
    --secondary: #06b6d4;     /* Electric Blue */

    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --font-outfit: 'Outfit', 'Noto Sans KR', sans-serif;
    --font-sans: 'Noto Sans KR', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 40%);
}

/* App Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-column: column;
    flex-direction: column;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.logo-icon {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.logo-icon i {
    color: white;
    width: 22px;
    height: 22px;
}

.logo-text {
    font-family: var(--font-outfit);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #d8b4fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--border-radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
}

.nav-item i {
    width: 20px;
    height: 20px;
    transition: var(--transition-smooth);
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: white;
    background-color: var(--primary-glow);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
}

.nav-item.active i {
    color: var(--primary);
    filter: drop-shadow(0 0 5px var(--primary));
}

/* Sidebar Streak Card */
.streak-card {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.02));
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.streak-icon {
    background-color: rgba(245, 158, 11, 0.15);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.streak-icon i {
    color: var(--warning);
    width: 24px;
    height: 24px;
    animation: flame-pulse 2s infinite ease-in-out;
}

.streak-info {
    font-size: 0.9rem;
}

.streak-count {
    font-family: var(--font-outfit);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--warning);
}

.streak-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 2px;
}

/* Main Content Styles */
.main-content {
    padding: 2.5rem 3.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
    max-height: 100vh;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.header-title h1 {
    font-size: 1.85rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.date-badge {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: var(--border-radius-md);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary));
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.25);
}

.btn-icon {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-icon:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.08);
}

/* Card - Premium Glassmorphism */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
}

.card:hover {
    background-color: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    width: 20px;
    height: 20px;
}

/* Grids & Utility Layouts */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-3-2 {
    grid-template-columns: 3fr 2fr;
}

.grid-2-3 {
    grid-template-columns: 2fr 3fr;
}

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

.flex-column {
    display: flex;
    flex-direction: column;
}

.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }

.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

/* Text Utilities */
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-bold { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.mb-lg { margin-bottom: 1.5rem; }
.mt-md { margin-top: 1rem; }
.border-top { border-top: 1px solid var(--border-color); }
.pt-md { padding-top: 1rem; }

.badge {
    background-color: var(--primary-glow);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
    gap: 1rem;
}

.empty-state i {
    width: 48px;
    height: 48px;
    stroke-width: 1.5;
}

/* Today's Checklist items */
/* Today's Checklist Grid (버튼식 칩 레이아웃) */
.checklist-container.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    max-height: 480px;
    overflow-y: auto;
    padding: 0.25rem;
    padding-right: 0.25rem;
}

/* 개별 복용 버튼 */
.checklist-btn {
    position: relative;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 0.95rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
    width: 100%;
    outline: none;
    font-family: var(--font-sans);
    color: var(--text-primary);
}

.checklist-btn:hover {
    background-color: rgba(139, 92, 246, 0.04);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.15);
}

/* 완료 상태 (복용 완료) */
.checklist-btn.taken {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
    border-color: var(--success);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.1);
}

.checklist-btn.taken:hover {
    background-color: rgba(16, 185, 129, 0.12);
    transform: translateY(-2px);
}

/* 체크 아이콘 */
.btn-check-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.btn-check-icon i {
    width: 22px;
    height: 22px;
    stroke-width: 2px;
    transition: var(--transition-smooth);
}

.checklist-btn:hover .btn-check-icon {
    color: var(--primary);
}

.checklist-btn.taken .btn-check-icon {
    color: var(--success);
    filter: drop-shadow(0 0 4px var(--success));
}

/* 내부 텍스트 콘텐츠 */
.btn-pill-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
    overflow: hidden;
}

.btn-pill-time {
    font-family: var(--font-outfit);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    transition: var(--transition-smooth);
}

.checklist-btn.taken .btn-pill-time {
    color: var(--success);
}

.btn-pill-name {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    color: var(--text-primary);
    transition: var(--transition-smooth);
}

.checklist-btn.taken .btn-pill-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* 메모 점 알림 */
.btn-pill-memo-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--secondary);
    box-shadow: 0 0 6px var(--secondary);
}

/* Circular Progress Ring */
.progress-card-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}

.progress-ring-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    stroke-dasharray: 502.65; /* 2 * PI * 80 */
    stroke-dashoffset: 502.65;
}

.progress-ring-text {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.progress-percentage {
    font-family: var(--font-outfit);
    font-size: 2.2rem;
    font-weight: 700;
}

.progress-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Info Stat Cards */
.info-stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.info-value {
    font-family: var(--font-outfit);
    font-size: 1.75rem;
    font-weight: 700;
}

.info-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 2. Calendar Tab Styles */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.calendar-month-year {
    font-size: 1.1rem;
    font-weight: 600;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

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

.calendar-day {
    aspect-ratio: 1;
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    font-family: var(--font-outfit);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.calendar-day:hover {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.2);
}

.calendar-day.empty {
    visibility: hidden;
    cursor: default;
}

.calendar-day.selected {
    border-color: var(--primary);
    background-color: var(--primary-glow);
    font-weight: 700;
}

.calendar-day.today {
    border: 2px dashed var(--secondary);
    color: var(--secondary);
}

/* Compliance status indicators in calendar */
.calendar-dots {
    position: absolute;
    bottom: 6px;
    display: flex;
    gap: 3px;
}

.dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.dot.full { background-color: var(--success); }
.dot.partial { background-color: var(--warning); }
.dot.none { background-color: var(--danger); }

/* Flat horizontal Progress bar (e.g. for Calendar side) */
.progress-bar-flat-bg {
    background-color: rgba(255, 255, 255, 0.05);
    height: 8px;
    border-radius: 50px;
    width: 100%;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-bar-flat {
    height: 100%;
    border-radius: 50px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    transition: var(--transition-smooth);
}

/* 3. Pill Cabinet Tab Styles */
.cabinet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.pill-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
    height: auto;
    gap: 1rem;
}

.pill-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.pill-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.pill-card-time {
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pill-card-days {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.pill-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    margin-top: auto;
}

/* Custom Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: var(--success);
}

/* Modal Overlay & Panel */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(6, 9, 21, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 100%;
    max-width: 500px;
    border-radius: var(--border-radius-lg);
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: var(--transition-smooth);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    outline: none;
    transition: var(--transition-smooth);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
    background-color: rgba(255, 255, 255, 0.05);
}

select.form-control {
    line-height: normal;
}

select.form-control option {
    background-color: var(--bg-sidebar);
    color: var(--text-primary);
}

textarea.form-control {
    resize: none;
}

/* Weekday multi-selector inside Modal */
.weekday-selector {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-top: 4px;
}

.day-checkbox {
    cursor: pointer;
}

.day-checkbox input {
    display: none;
}

.day-checkbox span {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.02);
    transition: var(--transition-smooth);
}

.day-checkbox:hover span {
    border-color: var(--primary);
    color: var(--text-primary);
}

.day-checkbox input:checked + span {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 700;
    box-shadow: 0 0 8px var(--primary-glow);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* Tab Panel visibility controller */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Analytics Tab styling */
.chart-container {
    position: relative;
    height: 320px;
    width: 100%;
}

.pill-stats-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.pill-stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pill-stat-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.progress-bar-container {
    height: 10px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(to right, var(--secondary), var(--primary));
    transition: width 0.8s ease-in-out;
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1100;
}

.toast {
    background-color: rgba(16, 22, 38, 0.9);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    transform: translateX(100px);
    opacity: 0;
    transition: var(--transition-smooth);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-warning { border-left: 4px solid var(--warning); }
.toast.toast-info { border-left: 4px solid var(--primary); }

.toast i {
    width: 18px;
    height: 18px;
}

/* Keyframes Animations */
@keyframes flame-pulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.5)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.8)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.5)); }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 재고 관련 뱃지 */
.pill-card-stock-info {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-weight: 500;
}

.stock-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stock-badge.warning {
    background-color: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.stock-badge.safe {
    background-color: rgba(16, 185, 129, 0.1);
    color: #a7f3d0;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* 모바일 하단 탭바 기본 숨김 */
.mobile-nav-bar {
    display: none;
}

/* Responsive styles */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        padding-bottom: 75px; /* 하단 탭바 여백 */
    }
    
    .sidebar {
        display: none !important;
    }
    
    .main-content {
        padding: 1.5rem 1rem;
        max-height: calc(100vh - 75px);
    }

    .grid-3-2, .grid-2-3 {
        grid-template-columns: 1fr;
    }

    /* 모바일 하단바 활성화 및 에어글로우 네온 피팅 */
    .mobile-nav-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        background-color: rgba(16, 22, 38, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color);
        justify-content: space-around;
        align-items: center;
        z-index: 999;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5), 0 -2px 10px rgba(139, 92, 246, 0.15); /* 은은한 보라빛 에어글로우 */
        padding: 0 0.5rem;
    }
    
    .mobile-nav-item {
        background: transparent;
        border: none;
        outline: none;
        color: var(--text-secondary);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        flex: 1;
        height: 100%;
        font-size: 0.75rem;
        font-weight: 500;
        cursor: pointer;
        transition: var(--transition-smooth);
    }
    
    .mobile-nav-item i {
        width: 20px;
        height: 20px;
        transition: var(--transition-smooth);
    }
    
    .mobile-nav-item:hover {
        color: var(--text-primary);
    }
    
    .mobile-nav-item.active {
        color: white;
        position: relative;
    }
    
    .mobile-nav-item.active i {
        color: var(--primary);
        filter: drop-shadow(0 0 6px var(--primary));
        transform: translateY(-2px);
    }
    
    .mobile-nav-item.active span {
        color: white;
        font-weight: 700;
    }
    
    /* 활성 탭 인디케이터 라인 */
    .mobile-nav-item.active::after {
        content: '';
        position: absolute;
        top: 0;
        width: 30px;
        height: 3px;
        background-color: var(--primary);
        border-radius: 0 0 3px 3px;
        box-shadow: 0 2px 10px var(--primary);
    }
}

/* ==========================================
   Interactions Tab Custom Styles
   ========================================== */
.interaction-alert-card {
    background: rgba(239, 68, 68, 0.03);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    transition: var(--transition-smooth);
}

.interaction-alert-card:hover {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.25);
}

.interaction-alert-card.caution {
    background: rgba(245, 158, 11, 0.03);
    border-color: rgba(245, 158, 11, 0.15);
}

.interaction-alert-card.caution:hover {
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.25);
}

.interaction-alert-card.synergy {
    background: rgba(16, 185, 129, 0.03);
    border-color: rgba(16, 185, 129, 0.15);
}

.interaction-alert-card.synergy:hover {
    background: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.25);
}

.alert-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    margin-bottom: 0.5rem;
}
.alert-badge.danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.alert-badge.caution { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.alert-badge.synergy { background: rgba(16, 185, 129, 0.15); color: #a7f3d0; }

.benefit-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    transition: var(--transition-smooth);
}

.benefit-card:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.12);
}

.benefit-badge {
    background: var(--primary-glow);
    color: var(--primary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 0.5rem;
}

/* ==========================================
   Desktop Viewport Optimization (Fits Screen)
   ========================================== */
@media (min-width: 1025px) {
    /* 화면 세로 높이에 비례하여 패딩과 크기를 조절하여 짤림 방지 및 한눈에 들어오는 레이아웃 완성 */
    .main-content {
        padding: 1.5rem 2rem;
        gap: 1rem;
        max-height: 100vh;
        overflow-y: auto;
    }

    .header {
        padding-bottom: 1rem;
    }

    .header-title h1 {
        font-size: 1.6rem;
    }

    .grid {
        gap: 1rem;
    }

    /* 달력 셀의 높이가 지나치게 비대해지는 현상 방지 */
    .calendar-day {
        aspect-ratio: auto;
        height: 6.2vh;
        min-height: 48px;
        max-height: 64px;
    }

    .calendar-day .day-number {
        margin-top: -6px;
    }

    .calendar-dots {
        bottom: 5px;
    }

    .calendar-header {
        margin-bottom: 0.75rem;
    }

    .calendar-weekdays {
        margin-bottom: 0.5rem;
    }

    /* 수납장 및 대시보드 카드 레이아웃 압축 */
    .card {
        padding: 1.25rem;
    }
}

/* ==========================================
   Premium Light Theme Overrides
   ========================================== */
.light-theme {
    --bg-main: #f8fafc;        /* Soft, crisp blue-gray backplate */
    --bg-sidebar: #ffffff;     /* Solid pure white sidebar */
    --bg-card: #ffffff;        /* Solid pure white card background (no semi-transparent washing out!) */
    --bg-card-hover: #ffffff;
    --border-color: #e2e8f0;   /* Solid light slate border */
    --border-hover: rgba(109, 40, 217, 0.5);
    
    --primary: #6d28d9;       /* Vibrant royal purple */
    --primary-glow: rgba(109, 40, 217, 0.08);
    --success: #047857;       /* Deep high-contrast forest emerald green */
    --success-glow: rgba(4, 120, 87, 0.08);
    --secondary: #0369a1;     /* High-contrast ocean blue */
    --warning: #b45309;       /* Deep warm amber */
    --danger: #b91c1c;        /* Deep crimson red */
    
    --text-primary: #111827;   /* Maximum contrast charcoal black */
    --text-secondary: #374151; /* Dark charcoal gray */
    --text-muted: #475569;     /* Saturated slate gray (super readable!) */
}

body.light-theme {
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(109, 40, 217, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.03) 0%, transparent 40%);
}

.light-theme .logo-text {
    background: linear-gradient(to right, #111827, #6d28d9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.light-theme .nav-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.light-theme .nav-item.active {
    color: var(--primary);
    background-color: rgba(109, 40, 217, 0.1); /* Slightly more opaque purple glow */
    border-left: 3.5px solid var(--primary);
}

.light-theme .date-badge,
.light-theme .btn-icon,
.light-theme .form-control {
    background-color: rgba(0, 0, 0, 0.02);
}

.light-theme .form-control:focus {
    background-color: rgba(255, 255, 255, 0.8);
}

.light-theme .form-control {
    color: var(--text-primary);
}

/* 라이트 테마: 하단 모바일 탭바 (기본은 어두운 배경 하드코딩이라 별도 보정) */
.light-theme .mobile-nav-bar {
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
}
.light-theme .mobile-nav-item {
    color: var(--text-secondary); /* 어두운 회색 — 흰 배경에서 잘 보임 */
}
.light-theme .mobile-nav-item.active,
.light-theme .mobile-nav-item.active span {
    color: var(--primary);
    font-weight: 700;
}
.light-theme .mobile-nav-item.active i {
    color: var(--primary);
    filter: none;
}

.light-theme .weekday-selector span {
    background-color: rgba(0, 0, 0, 0.01);
}

.light-theme .slider {
    background-color: rgba(0, 0, 0, 0.05);
}

.light-theme input:checked + .slider {
    background-color: rgba(4, 120, 87, 0.15);
}

.light-theme .slider:before {
    background-color: #9ca3af;
}

.light-theme input:checked + .slider:before {
    background-color: var(--success);
}

.light-theme .calendar-day {
    background-color: #ffffff;
    border-color: #e2e8f0;
}

.light-theme .calendar-day:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.light-theme .calendar-day.selected {
    border-color: var(--primary);
    background-color: rgba(109, 40, 217, 0.06);
    color: var(--primary);
    font-weight: 700;
}

.light-theme .calendar-day.today {
    border: 2px dashed var(--secondary);
    color: var(--secondary);
    background-color: rgba(3, 105, 161, 0.03);
}

.light-theme .btn-secondary {
    background-color: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
}

.light-theme .btn-secondary:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.light-theme .checklist-btn {
    background-color: #ffffff; /* Solid white background for perfect contrast against slate body */
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.light-theme .checklist-btn:hover {
    background-color: #faf5ff; /* Very soft purplish tint */
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.1);
}

.light-theme .checklist-btn.taken {
    background: #d1fae5; /* Solid beautiful mint green background! (very crisp) */
    border-color: rgba(4, 120, 87, 0.45); /* Elegant rich forest green border */
    box-shadow: 0 2px 8px rgba(4, 120, 87, 0.06);
}

.light-theme .checklist-btn.taken:hover {
    background-color: #a7f3d0; /* Saturated mint on hover */
    border-color: var(--success);
}

.light-theme .checklist-btn.taken .btn-check-icon {
    color: var(--success) !important;
}

.light-theme .checklist-btn.taken .btn-pill-time {
    color: var(--success) !important;
    font-weight: 700;
}

.light-theme .checklist-btn.taken .btn-pill-name {
    color: #334155; /* Slate dark gray, very legible when struck through! */
    text-decoration-color: rgba(4, 120, 87, 0.6); /* Color the strike-through line beautifully in green! */
}

/* Circular Progress Ring background circle visibility in Light Theme */
.light-theme .progress-ring__circle-bg {
    stroke: rgba(109, 40, 217, 0.15) !important; /* Soft royal purple track instead of dull gray */
}

/* Stock Warning Banner Light Theme Contrast */
.light-theme .stock-banner-card {
    background: linear-gradient(135deg, #fee2e2, #ffffff);
    border-color: rgba(185, 28, 28, 0.35); /* More visible border */
    box-shadow: 0 4px 15px rgba(185, 28, 28, 0.04);
}

.light-theme .stock-banner-icon {
    background-color: rgba(185, 28, 28, 0.15);
    color: var(--danger);
}

/* Sidebar Streak Card Light Theme Contrast */
.light-theme .streak-card {
    background: linear-gradient(135deg, #fef3c7, #ffffff);
    border: 1px solid rgba(180, 83, 9, 0.35);
    box-shadow: 0 4px 12px rgba(180, 83, 9, 0.03);
}

.light-theme .streak-icon {
    background-color: rgba(180, 83, 9, 0.15);
    color: var(--warning);
}

/* Stock Badges Light Theme Contrast */
.light-theme .stock-badge.warning {
    background-color: #fee2e2;
    color: #991b1b; /* Saturated deep dark red */
    border: 1px solid rgba(185, 28, 28, 0.3);
    font-weight: 700;
}

.light-theme .stock-badge.safe {
    background-color: #d1fae5;
    color: #065f46; /* Saturated deep forest green */
    border: 1px solid rgba(4, 120, 87, 0.3);
    font-weight: 700;
}

/* Toast Notifications Light Theme Contrast & Text Visibility */
.light-theme .toast {
    background-color: #ffffff; /* 100% opaque pure white */
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); /* Stronger shadow */
    font-weight: 500;
}

/* Synergy & Interaction Alert Badges Light Theme Contrast */
.light-theme .alert-badge.danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid rgba(185, 28, 28, 0.25);
    font-weight: 700;
}
.light-theme .alert-badge.caution {
    background: #fef3c7;
    color: #78350f;
    border: 1px solid rgba(180, 83, 9, 0.25);
    font-weight: 700;
}
.light-theme .alert-badge.synergy {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid rgba(4, 120, 87, 0.25);
    font-weight: 700;
}

.light-theme .interaction-alert-card {
    background: rgba(185, 28, 28, 0.02);
    border-color: rgba(185, 28, 28, 0.12);
}
.light-theme .interaction-alert-card:hover {
    background: rgba(185, 28, 28, 0.04);
    border-color: rgba(185, 28, 28, 0.2);
}
.light-theme .interaction-alert-card.caution {
    background: rgba(180, 83, 9, 0.02);
    border-color: rgba(180, 83, 9, 0.12);
}
.light-theme .interaction-alert-card.caution:hover {
    background: rgba(180, 83, 9, 0.04);
    border-color: rgba(180, 83, 9, 0.2);
}
.light-theme .interaction-alert-card.synergy {
    background: rgba(4, 120, 87, 0.02);
    border-color: rgba(4, 120, 87, 0.12);
}
.light-theme .interaction-alert-card.synergy:hover {
    background: rgba(4, 120, 87, 0.04);
    border-color: rgba(4, 120, 87, 0.2);
}

/* Analytics Tab Heatmap Grass Cells Light Theme Contrast */
.light-theme .lv1 { background-color: rgba(4, 120, 87, 0.2); }
.light-theme .lv2 { background-color: rgba(4, 120, 87, 0.45); }
.light-theme .lv3 { background-color: rgba(4, 120, 87, 0.75); }
.light-theme .lv4 { 
    background-color: rgba(4, 120, 87, 1); 
    box-shadow: 0 0 8px rgba(4, 120, 87, 0.3); 
}

.light-theme .benefit-card {
    background: rgba(0, 0, 0, 0.005);
}
.light-theme .benefit-card:hover {
    background: rgba(0, 0, 0, 0.015);
}

.light-theme .empty-state {
    color: var(--text-muted);
}

.light-theme .modal {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.12), 0 10px 20px -5px rgba(0, 0, 0, 0.08);
}

/* ==========================================
   Monthly Compliance Heatmap (Grass)
   ========================================== */
.heatmap-wrapper {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    max-width: 380px;
    margin: 0 auto;
}

@media (min-width: 480px) {
    .heatmap-wrapper {
        grid-template-columns: repeat(7, 1fr);
        max-width: 450px;
    }
}

.legend-cell, .heatmap-cell {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 3px;
    transition: var(--transition-smooth);
}

.legend-cell {
    display: inline-block;
    width: 14px;
    height: 14px;
}

.heatmap-cell {
    position: relative;
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scale(1.18);
    z-index: 10;
}

/* Heatmap cell coloring based on compliance rate */
.lv0 { background-color: rgba(255, 255, 255, 0.03); }
.light-theme .lv0 { background-color: rgba(0, 0, 0, 0.05); }

.lv1 { background-color: rgba(16, 185, 129, 0.2); }
.lv2 { background-color: rgba(16, 185, 129, 0.45); }
.lv3 { background-color: rgba(16, 185, 129, 0.7); }
.lv4 { 
    background-color: rgba(16, 185, 129, 1); 
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); 
}

/* ==========================================
   Dynamic Time Inputs inside Modal
   ========================================== */
.pill-time-row {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slide-in-time 0.25s ease-out;
}

@keyframes slide-in-time {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.btn-remove-time-field {
    background-color: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
    height: 38px;
    width: 38px;
    flex-shrink: 0;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-remove-time-field:hover {
    background-color: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #ef4444 !important;
}

.light-theme .btn-remove-time-field {
    background-color: rgba(239, 68, 68, 0.05) !important;
    border-color: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
}

/* ==========================================
   Condition Selector Chips
   ========================================== */
.condition-selector-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.condition-chip-label {
    cursor: pointer;
}

.cond-chip {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.light-theme .cond-chip {
    background-color: rgba(0, 0, 0, 0.02);
}

.cond-chip:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.condition-chip-label input:checked + .cond-chip {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 0 8px var(--primary-glow);
}

/* ==========================================
   Profile Selector Dropdown
   ========================================== */
.profile-select-container {
    position: relative;
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background-color: #101626;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    width: 200px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: var(--transition-smooth);
    padding: 0.5rem;
}

.profile-dropdown.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.profile-dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.profile-dropdown-item.active {
    background-color: var(--primary-glow);
    color: var(--primary);
    font-weight: 600;
}

.profile-dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}

.btn-profile-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-profile-delete:hover {
    color: var(--danger);
}

.light-theme .profile-dropdown {
    background-color: #ffffff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.light-theme .profile-dropdown-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* ==========================================
   Stock Warning Banner (Dashboard)
   ========================================== */
.stock-banner-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.02));
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--border-radius-lg);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    animation: slide-down 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.stock-banner-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stock-banner-icon {
    background-color: rgba(239, 68, 68, 0.15);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger);
    flex-shrink: 0;
}

.stock-banner-icon i {
    width: 18px;
    height: 18px;
}

.stock-banner-message {
    font-size: 0.85rem;
    font-weight: 500;
}

.stock-banner-message span {
    color: #fca5a5;
    font-weight: 700;
}

.light-theme .stock-banner-message span {
    color: var(--danger);
}

@keyframes slide-down {
    from { transform: translateY(-15px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==========================================
   Side Effects Log Styling
   ========================================== */
.side-effect-log-container {
    grid-column: 1 / -1; /* CSS Grid에서 1열부터 끝열까지 전체 차지 */
    width: 100%;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.side-effect-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.side-effect-input {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
    resize: vertical; /* 높이 조절 가능하도록 설정 */
    min-height: 90px; /* 더 넓고 쾌적한 입력란 */
    font-family: var(--font-sans);
    line-height: 1.5;
}

.side-effect-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 6px var(--primary-glow);
    background-color: rgba(255, 255, 255, 0.05);
}

.light-theme .side-effect-input {
    background-color: rgba(0, 0, 0, 0.02);
}

.light-theme .side-effect-input:focus {
    background-color: rgba(255, 255, 255, 0.8);
}

/* ==========================================
   A4 Printing Styles (@media print)
   ========================================== */
@media print {
    body {
        background-color: white !important;
        color: black !important;
        font-family: 'Noto Sans KR', sans-serif !important;
        background-image: none !important;
    }
    .sidebar, .header-actions, .mobile-nav-bar, .backup-control-bar, 
    .btn, button, #btn-theme-toggle, .profile-select-container, 
    .modal-overlay, .toast-container, .chart-container, .heatmap-legend, 
    .heatmap-wrapper, #dashboard-stock-banner, .calendar-detail-footer {
        display: none !important;
    }
    .app-container {
        display: block !important;
        grid-template-columns: 1fr !important;
    }
    .main-content {
        padding: 0 !important;
        max-height: none !important;
        overflow-y: visible !important;
    }
    .card {
        background: none !important;
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        margin-bottom: 2rem !important;
        page-break-inside: avoid;
    }
    
    /* Print specific report table layout */
    .print-only-report {
        display: block !important;
        color: black !important;
    }
    .print-report-header {
        border-bottom: 2px solid #000;
        padding-bottom: 1rem;
        margin-bottom: 2rem;
    }
    .print-report-header h2 {
        font-size: 1.8rem;
        font-weight: 700;
        margin-bottom: 4px;
    }
    .print-report-meta {
        font-size: 0.85rem;
        color: #555;
        margin-bottom: 1.5rem;
    }
    .print-section-title {
        font-size: 1.2rem;
        font-weight: 700;
        margin-top: 1.5rem;
        margin-bottom: 0.75rem;
        border-left: 4px solid #8b5cf6;
        padding-left: 8px;
    }
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 1.5rem;
    }
    .print-table th, .print-table td {
        border: 1px solid #ccc;
        padding: 8px 12px;
        text-align: left;
        font-size: 0.85rem;
        color: black !important;
    }
    .print-table th {
        background-color: #f3f4f6 !important;
        font-weight: bold;
    }
}

/* Hide print-only-report on screen */
.print-only-report {
    display: none;
}

/* ==========================================
   Next Dose Real-time Widget Styling
   ========================================== */
.next-dose-widget {
    margin-bottom: 1.5rem;
    padding: 1.2rem 1.5rem;
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
    animation: slide-down 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.next-dose-widget:hover {
    transform: translateY(-2px);
}

/* 1. Upcoming Dose (Radiant Violet Theme) */
.next-dose-widget.upcoming {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(139, 92, 246, 0.02));
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.08), inset 0 0 10px rgba(139, 92, 246, 0.04);
}
.next-dose-widget.upcoming .next-dose-icon-wrapper {
    background-color: rgba(139, 92, 246, 0.15);
    color: var(--primary);
}
.next-dose-widget.upcoming .next-dose-countdown-badge {
    background-color: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(139, 92, 246, 0.25);
}

/* 2. Delayed Dose (Warm Amber Theme for Missed Alarms) */
.next-dose-widget.delayed {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.02));
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.08), inset 0 0 10px rgba(245, 158, 11, 0.04);
}
.next-dose-widget.delayed .next-dose-icon-wrapper {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    animation: flame-pulse 2s infinite ease-in-out;
}
.next-dose-widget.delayed .next-dose-countdown-badge {
    background-color: rgba(245, 158, 11, 0.12);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* 3. Completed Dose (Emerald Green Theme) */
.next-dose-widget.completed {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
    border-color: rgba(16, 185, 129, 0.25);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.06), inset 0 0 10px rgba(16, 185, 129, 0.03);
}
.next-dose-widget.completed .next-dose-icon-wrapper {
    background-color: rgba(16, 185, 129, 0.12);
    color: var(--success);
}
.next-dose-widget.completed .next-dose-countdown-badge {
    background-color: var(--success-glow);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Layout details */
.next-dose-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.next-dose-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.next-dose-icon-wrapper i {
    width: 22px;
    height: 22px;
}

.next-dose-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.next-dose-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.next-dose-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.next-dose-countdown-badge {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-md);
    font-family: var(--font-outfit);
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Light Theme Overrides */
.light-theme .next-dose-widget {
    background-color: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.light-theme .next-dose-widget.upcoming {
    background: linear-gradient(135deg, #faf5ff, #ffffff);
    border-color: rgba(109, 40, 217, 0.35); /* Saturated royal purple border */
    box-shadow: 0 6px 20px rgba(109, 40, 217, 0.04);
}
.light-theme .next-dose-widget.upcoming .next-dose-icon-wrapper {
    background-color: rgba(109, 40, 217, 0.15);
    color: var(--primary);
}
.light-theme .next-dose-widget.upcoming .next-dose-countdown-badge {
    background-color: var(--primary); /* Solid royal purple background! */
    color: #ffffff !important;         /* Opaque white text for absolute contrast */
    border: none;
    box-shadow: 0 3px 8px rgba(109, 40, 217, 0.3);
}

.light-theme .next-dose-widget.delayed {
    background: linear-gradient(135deg, #fffbeb, #ffffff);
    border-color: rgba(180, 83, 9, 0.45); /* Saturated amber border */
    box-shadow: 0 6px 20px rgba(180, 83, 9, 0.04);
}
.light-theme .next-dose-widget.delayed .next-dose-icon-wrapper {
    background-color: rgba(180, 83, 9, 0.18);
    color: var(--warning);
}
.light-theme .next-dose-widget.delayed .next-dose-countdown-badge {
    background-color: var(--warning); /* Solid warm amber background! */
    color: #ffffff !important;         /* Opaque white text for absolute contrast */
    border: none;
    box-shadow: 0 3px 8px rgba(180, 83, 9, 0.3);
}

.light-theme .next-dose-widget.completed {
    background: linear-gradient(135deg, #ecfdf5, #ffffff);
    border-color: rgba(4, 120, 87, 0.4); /* Solid forest green border */
    box-shadow: 0 6px 20px rgba(4, 120, 87, 0.04);
}
.light-theme .next-dose-widget.completed .next-dose-icon-wrapper {
    background-color: rgba(4, 120, 87, 0.15);
    color: var(--success);
}
.light-theme .next-dose-widget.completed .next-dose-countdown-badge {
    background-color: var(--success); /* Solid deep forest green background! */
    color: #ffffff !important;        /* Opaque white text for absolute contrast */
    border: none;
    box-shadow: 0 3px 8px rgba(4, 120, 87, 0.25);
}

/* ==========================================
   로그인 / 회원가입 화면 (auth.js)
   ========================================== */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg-main);
    background-image:
        radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.15) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.10) 0%, transparent 45%);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2.2rem 2rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-family: var(--font-outfit);
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--text-primary);
}
.auth-logo i { width: 30px; height: 30px; color: var(--primary); }
.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0.5rem 0 1.5rem;
}
.auth-tabs {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 4px;
    margin-bottom: 1.4rem;
}
.auth-tab {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-field { margin-bottom: 1rem; }
.auth-field label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
.auth-field input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}
.auth-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.auth-error {
    color: var(--danger);
    font-size: 0.82rem;
    min-height: 1.1rem;
    margin: 0.2rem 0 0.6rem;
}
.auth-submit {
    width: 100%;
    justify-content: center;
    padding: 0.8rem;
    font-size: 0.98rem;
}
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ==========================================
   모바일 최적화 보강 (safe-area / 헤더 / 터치 타깃)
   ========================================== */

/* iOS 노치/홈 인디케이터 안전 영역 — 하단 탭바와 본문 여백 */
@media (max-width: 1024px) {
    .app-container {
        /* 탭바 70px + 홈 인디케이터 여백 */
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }
    .mobile-nav-bar {
        height: calc(70px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .main-content {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    /* 터치 타깃 최소 44px 확보 */
    .btn-icon { min-width: 44px; min-height: 44px; }
}

/* 좁은 화면(휴대폰) 헤더 정리 — 줄바꿈 허용 + 불필요 요소 축약 */
@media (max-width: 640px) {
    .header {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding-bottom: 1rem;
    }
    .header-title h1 { font-size: 1.4rem; }
    .header-title p { font-size: 0.82rem; }
    .header-actions {
        width: 100%;
        gap: 0.6rem;
        flex-wrap: wrap;
    }
    /* 날짜 배지는 모바일에서 숨김(상단 탭/대시보드에서 날짜 확인 가능) */
    .date-badge { display: none; }
    /* '영양제 추가' 버튼은 아이콘만 — 텍스트 숨김으로 폭 절약 */
    #btn-add-pill-header span { display: none; }
    #btn-add-pill-header { padding: 0.65rem; min-width: 44px; min-height: 44px; }
    /* 프로필 선택기는 남은 폭을 채우도록 */
    .profile-select-container { flex: 1; }
    #btn-profile-selector { width: 100%; justify-content: center; }
}

/* 로그인 화면 안전 영역 */
.auth-overlay {
    padding-top: max(1.5rem, env(safe-area-inset-top));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

/* ==========================================
   계정 설정 / 관리자 모달 (account.js)
   ========================================== */
.acct-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.acct-card {
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.acct-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-sidebar);
    z-index: 1;
}
.acct-head h3 { font-size: 1.1rem; font-weight: 600; }
.acct-body { padding: 1.4rem; }
.acct-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 4px;
    margin-bottom: 1.3rem;
}
.acct-tab {
    flex: 1;
    padding: 0.55rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}
.acct-tab.active { background: var(--primary); color: #fff; }
.acct-sec label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0.9rem 0 0.4rem;
}
.acct-sec input[type="text"], .acct-sec input[type="password"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
}
.acct-sec input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.acct-submit { width: 100%; justify-content: center; margin-top: 1.2rem; padding: 0.75rem; }
.acct-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.6rem; }
.acct-warn {
    font-size: 0.88rem;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--border-radius-md);
    padding: 0.8rem;
    margin-bottom: 0.5rem;
}

/* 관리자 사용자 테이블 */
.acct-table-wrap { overflow-x: auto; }
.acct-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.acct-table th, .acct-table td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.acct-table th { color: var(--text-secondary); font-weight: 600; }
.acct-num { text-align: center; }
.acct-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.acct-badge.admin {
    display: inline-block;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--primary-glow);
    color: var(--primary);
    margin-left: 4px;
}
.acct-mini {
    padding: 0.3rem 0.55rem;
    font-size: 0.74rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}
.acct-mini:hover { border-color: var(--primary); color: var(--primary); }
.acct-mini.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ==========================================
   처방전 스캐너 (prescription.js)
   ========================================== */
.prescription-scanner-card { border: 1px dashed var(--border-hover); }
.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}
.upload-dropzone:hover { border-color: var(--primary); background-color: var(--primary-glow); }
.upload-prompt { font-size: 0.88rem; color: var(--text-secondary); }

.scan-preview-container {
    position: relative;
    width: 100%;
    max-height: 320px;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}
#prescription-img-preview {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    display: block;
    filter: brightness(0.55) blur(1px);
}
.laser-scanner-line {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    box-shadow: 0 0 12px var(--primary);
    animation: laser-scan 2.2s infinite ease-in-out;
}
.scan-overlay-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: 600;
    font-size: 0.92rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    text-align: center;
    width: 90%;
    pointer-events: none;
}
@keyframes laser-scan {
    0% { top: 0%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

.pill-chip-group { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.scan-empty { font-size: 0.84rem; color: var(--text-muted); }
.scan-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.4rem 0.6rem;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
}
.scan-chip-x {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
.scan-chip-x:hover { color: var(--danger); }
.scan-add-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.scan-add-row input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
}
.scan-add-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.scan-actions { display: flex; gap: 0.5rem; }
.scan-report { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.scan-note {
    font-size: 0.82rem;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 0.7rem 0.85rem;
    line-height: 1.5;
    word-break: keep-all;
}

/* 모바일 화면에서 복용 체크리스트를 1줄에 2개씩 배치 */
@media (max-width: 768px) {
    .checklist-container.button-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }
    .checklist-btn {
        padding: 0.8rem 0.6rem !important;
        gap: 0.5rem !important;
    }
    .btn-check-icon i {
        width: 18px !important;
        height: 18px !important;
    }
    .btn-pill-name {
        font-size: 0.85rem !important;
    }
    .btn-pill-time {
        font-size: 0.7rem !important;
    }
}



