@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;600&display=swap');

:root {
    /* Primary Colors */
    --primary-500: #3B82F6;
    --primary-400: #60A5FA;
    --primary-600: #2563EB;
    --primary-100: #DBEAFE;

    /* Neutral Colors */
    --gray-900: #111827;
    --gray-700: #374151;
    --gray-500: #6B7280;
    --gray-300: #D1D5DB;
    --gray-100: #F3F4F6;
    --white: #FFFFFF;

    /* Semantic Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;

    /* Reservation Status Colors */
    --status-reserved: #60A5FA;
    --status-confirmed: #3B82F6;
    --status-ongoing: #F59E0B;
    --status-completed: #10B981;
    --status-cancelled: rgba(156, 163, 175, 0.5);
    --status-noshow: #EF4444;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Font Families */
    --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Roboto Mono', 'SF Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
}

/* Layout */
.app-container {
    max-width: 640px;
    /* Mobile first by default */
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--white);
    position: relative;
    box-shadow: var(--shadow-md);
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 100%;
        flex-direction: row;
    }
}

/* Header */
.header {
    height: 56px;
    padding: 0 var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--gray-300);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    font-size: 18px;
    color: var(--gray-900);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Bottom Navigation */
.bottom-nav {
    height: 56px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--gray-300);
    display: flex;
    position: sticky;
    bottom: 0;
    width: 100%;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--gray-500);
    font-size: 10px;
    gap: 2px;
}

.nav-item.active {
    color: var(--primary-500);
}

.nav-item i {
    font-size: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: var(--space-lg);
    padding-bottom: 80px;
    /* Space for bottom nav */
}

/* Glassmorphism Cards */
.card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: rgba(255, 255, 255, 0.8);
}

.card:active {
    transform: scale(0.98);
}

/* Tab Navigation Animation */
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--gray-500);
    font-size: 10px;
    gap: 2px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.nav-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: var(--primary-100);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: all 0.4s ease;
}

.nav-item:active::after {
    width: 100px;
    height: 100px;
    opacity: 0.5;
}

.nav-item.active {
    color: var(--primary-500);
}

.nav-item i {
    font-size: 20px;
    transition: transform 0.2s ease;
}

.nav-item.active i {
    transform: translateY(-2px);
}

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

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

.main-content>* {
    animation: fadeIn 0.4s ease-out forwards;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* Floating Action Button */
.fab-btn {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--white);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: absolute;
    top: -28px;
    z-index: 101;
}

.fab-btn:active {
    transform: scale(0.9) translateY(4px);
}

.fab-btn i {
    width: 28px;
    height: 28px;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
    width: calc(100% - 40px);
    max-width: 400px;
}

.toast {
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(8px);
    color: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

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

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

.toast-error {
    border-left: 4px solid var(--error);
}

/* Modal Overlay & Bottom Sheet */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    visibility: visible;
    opacity: 1;
}

.bottom-sheet {
    width: 100%;
    background: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.show .bottom-sheet {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 32px;
    height: 4px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    margin: 12px auto;
}

/* Utilities */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    outline: none;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--white);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
    filter: brightness(1.1);
}

.btn-icon {
    padding: var(--space-sm);
    border-radius: var(--radius-full);
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-xs);
}

.form-control,
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-300);
    background: var(--white);
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--gray-900);
    transition: all 0.2s ease;
    outline: none;
}

.droppable-area {
    transition: background-color 0.15s ease;
    cursor: pointer;
    min-height: 40px;
    touch-action: none;
    /* Prevent scrolling while dragging on mobile */
}

.form-control:focus,
input[type="text"]:focus,
input[type="tel"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-500);
    background: #eff6ff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.text-mono {
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

.badge {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-blue {
    background: var(--primary-100);
    color: var(--primary-600);
}

.badge-green {
    background: #DCFCE7;
    color: var(--success);
}

.badge-yellow {
    background: #FEF3C7;
    color: var(--warning);
}

.badge-red {
    background: #FEE2E2;
    color: var(--error);
}

/* Calendar Views Layouts */
.calendar-view-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 80px;
}

.view-hidden {
    display: none !important;
}

/* Day/Week View Common */
.time-grid {
    display: flex;
    flex-direction: column;
    background: var(--gray-300);
    gap: 1px;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.time-row {
    display: flex;
    background: var(--white);
    min-height: 80px;
    position: relative;
}

.time-label {
    width: 50px;
    padding: var(--space-sm);
    border-right: 1px solid var(--gray-100);
    color: var(--gray-500);
    font-size: 11px;
    text-align: right;
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.grid-content {
    flex: 1;
    position: relative;
    display: flex;
    gap: 1px;
}

/* Week View Specific */
.week-header {
    display: flex;
    padding-left: 50px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 20;
}

.week-header-day {
    flex: 1;
    text-align: center;
    padding: var(--space-sm) 0;
    font-size: 11px;
    color: var(--gray-500);
}

.week-header-day .date {
    font-size: 15px;
    font-weight: 700;
    display: block;
    color: var(--gray-900);
    width: 28px;
    height: 28px;
    line-height: 28px;
    margin: 2px auto;
}

.week-header-day.today .date {
    background: var(--primary-500);
    color: var(--white);
    border-radius: 50%;
}

.week-col {
    flex: 1;
    height: 100%;
    position: relative;
    border-right: 1px solid var(--gray-100);
}

/* Month View */
.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--gray-200);
    gap: 1px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.month-header-day {
    background: var(--gray-50);
    padding: var(--space-sm) 0;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
}

.month-cell {
    background: var(--white);
    min-height: 100px;
    padding: 2px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.month-cell .day-num {
    font-size: 11px;
    font-weight: 600;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}

.month-cell.today .day-num {
    background: var(--primary-500);
    color: var(--white);
    border-radius: 50%;
}

.month-event {
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 2px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 1px;
    font-weight: 500;
    line-height: 1.2;
}

.month-event.ongoing {
    background: var(--status-ongoing);
}

.month-event.confirmed {
    background: var(--status-confirmed);
}

.month-event.completed {
    background: var(--status-completed);
}

.month-event-more {
    font-size: 9px;
    color: var(--gray-500);
    padding-left: 4px;
    font-weight: 600;
    margin-top: 1px;
}

.month-cell.other-month {
    color: var(--gray-400);
    background: var(--gray-50);
}

.density-low {
    background: #eff6ff;
}

.density-med {
    background: #dbeafe;
}

.density-high {
    background: #bfdbfe;
}

.status-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: auto;
}

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

.dot-primary {
    background: var(--primary-500);
}

.dot-success {
    background: var(--success);
}

.dot-error {
    background: var(--error);
}

.calendar-block {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 4px;
    padding: 4px;
    color: white;
    font-size: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.calendar-block.block-sm {
    height: 38px;
}

.calendar-block.block-md {
    height: 78px;
}

.calendar-block.block-lg {
    height: 118px;
}

/* Calendar Filter Styles */
.filter-select {
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    font-size: 13px;
    color: var(--gray-700);
    min-width: 120px;
    cursor: pointer;
}

.filter-select:focus {
    border-color: var(--primary-500);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Outside Business Hours */
.time-row.outside-hours {
    background: repeating-linear-gradient(135deg,
            var(--gray-100),
            var(--gray-100) 10px,
            var(--gray-50) 10px,
            var(--gray-50) 20px);
    opacity: 0.7;
}

.time-row.outside-hours .time-label {
    color: var(--gray-400);
}

[data-theme="dark"] .time-row.outside-hours {
    background: repeating-linear-gradient(135deg,
            rgba(55, 65, 81, 0.5),
            rgba(55, 65, 81, 0.5) 10px,
            rgba(31, 41, 55, 0.5) 10px,
            rgba(31, 41, 55, 0.5) 20px);
}

/* Current Time Line */
.current-time-line {
    position: absolute;
    height: 2px;
    background: var(--error);
    z-index: 15;
    pointer-events: none;
}

.current-time-line::before {
    content: '';
    position: absolute;
    left: -5px;
    top: -4px;
    width: 10px;
    height: 10px;
    background: var(--error);
    border-radius: 50%;
}

/* Drag Selection Indicator (Google Calendar Style) */
.drag-selection-block {
    position: absolute;
    background: rgba(59, 130, 246, 0.2);
    border: 2px solid var(--primary-500);
    border-radius: 4px;
    z-index: 40;
    pointer-events: none;
    /* Let clicks pass through except for the button */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
    transition: opacity 0.2s ease;
}

.drag-selection-content {
    pointer-events: auto;
    /* Enable clicks for the button */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--white);
    padding: 8px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-300);
    min-width: 120px;
}

.drag-selection-time {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-700);
}

.btn-create-res {
    background: var(--primary-500);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.btn-create-res:hover {
    background: var(--primary-600);
}

/* Hover Effect for empty areas */
.droppable-area:not(.outside-hours):hover {
    background-color: rgba(59, 130, 246, 0.08) !important;
}

/* Drag Selection Highlight Legacy - keeping for compat but unused with new logic */
.droppable-area.drag-highlight {
    background-color: rgba(59, 130, 246, 0.1) !important;
}

[data-theme="dark"] .droppable-area.drag-highlight {
    background-color: rgba(96, 165, 250, 0.3) !important;
}

.calendar-block[draggable="true"]:hover {
    cursor: grab;
    box-shadow: var(--shadow-md);
}

.calendar-block[draggable="true"]:active {
    cursor: grabbing;
}

/* Overlap Warning Styles */
.calendar-block.has-overlap {
    border: 2px solid var(--warning);
    animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0);
    }
}

/* Week Header Fix */
.week-header {
    display: flex;
    padding-left: 0;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 20;
}

/* ============================================
   DARK MODE
   ============================================ */

[data-theme="dark"] {
    /* Primary Colors - slightly adjusted for dark mode */
    --primary-500: #60A5FA;
    --primary-400: #93C5FD;
    --primary-600: #3B82F6;
    --primary-100: rgba(59, 130, 246, 0.2);

    /* Neutral Colors - inverted */
    --gray-900: #F9FAFB;
    --gray-700: #E5E7EB;
    --gray-500: #9CA3AF;
    --gray-300: #374151;
    --gray-100: #1F2937;
    --white: #111827;

    /* Semantic Colors - slightly brighter for dark mode */
    --success: #34D399;
    --warning: #FBBF24;
    --error: #F87171;
    --info: #60A5FA;

    /* Shadows - adjusted for dark mode */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] body {
    background-color: #0F172A;
}

[data-theme="dark"] .app-container {
    background-color: #111827;
}

[data-theme="dark"] .header {
    background: rgba(17, 24, 39, 0.8);
    border-bottom-color: var(--gray-300);
}

[data-theme="dark"] .bottom-nav {
    background: rgba(17, 24, 39, 0.9);
    border-top-color: var(--gray-300);
}

[data-theme="dark"] .card {
    background: rgba(31, 41, 55, 0.7);
    border-color: rgba(55, 65, 81, 0.5);
}

[data-theme="dark"] .card:hover {
    background: rgba(31, 41, 55, 0.9);
}

[data-theme="dark"] .bottom-sheet {
    background: #1F2937;
}

[data-theme="dark"] .bottom-sheet-handle {
    background: var(--gray-500);
}

[data-theme="dark"] .toast {
    background: rgba(249, 250, 251, 0.95);
    color: #111827;
}

[data-theme="dark"] .time-grid {
    background: var(--gray-300);
}

[data-theme="dark"] .time-row {
    background: var(--white);
}

[data-theme="dark"] .time-label {
    border-right-color: var(--gray-300);
}

[data-theme="dark"] .week-header {
    background: var(--white);
    border-bottom-color: var(--gray-300);
}

[data-theme="dark"] .week-col {
    border-right-color: var(--gray-300);
}

[data-theme="dark"] .month-grid {
    background: var(--gray-300);
    border-color: var(--gray-300);
}

[data-theme="dark"] .month-header-day {
    background: #1F2937;
}

[data-theme="dark"] .month-cell {
    background: var(--white);
}

[data-theme="dark"] .month-cell.other-month {
    background: #1a1f2e;
}

[data-theme="dark"] .density-low {
    background: rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .density-med {
    background: rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .density-high {
    background: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #1F2937;
    color: #F9FAFB;
    border-color: #374151;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #6B7280;
}

[data-theme="dark"] .nav-item::after {
    background: rgba(96, 165, 250, 0.2);
}

/* Dark mode toggle switch styling */
.theme-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--gray-300);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.theme-toggle.active {
    background: var(--primary-500);
}

.theme-toggle::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--white);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

.theme-toggle.active::after {
    transform: translateX(16px);
}

[data-theme="dark"] .theme-toggle {
    background: var(--primary-500);
}

[data-theme="dark"] .theme-toggle::after {
    background: #F9FAFB;
    transform: translateX(16px);
}