:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --surface: #ffffff;
    --background: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
    margin-bottom: 2.5rem;
}

.logo i {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 1.25rem;
}

.nav-item:hover {
    background-color: var(--background);
    color: var(--text-main);
}

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

.upcoming-summary {
    margin-top: 2rem;
}

.upcoming-summary h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.mini-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mini-event {
    padding: 0.75rem;
    background-color: var(--background);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary);
}

.mini-event h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.mini-event p {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 72px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
}

.topbar h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.month-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.month-navigation h3 {
    font-size: 1.125rem;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
}

.icon-btn:hover {
    background-color: var(--background);
    color: var(--text-main);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.content-grid {
    flex: 1;
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

.calendar-section, .list-section, .admin-section {
    flex: 1;
    min-width: 0;
}

.registration-section {
    width: 400px;
    flex-shrink: 0;
    order: -1;
}

/* Cards */
.card {
    background-color: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Calendar */
.calendar-section {
    height: 100%;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 500;
    color: var(--text-muted);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.calendar-body {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(100px, 1fr);
}

.calendar-day {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: background-color 0.2s;
}

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

.calendar-day:hover {
    background-color: var(--background);
}

.calendar-day.other-month {
    background-color: #fcfcfc;
    color: #cbd5e1;
}

.day-number {
    font-size: 0.875rem;
    font-weight: 500;
    align-self: flex-end;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.calendar-day.today .day-number {
    background-color: var(--primary);
    color: white;
}

/* Event Tags */
.event-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background-color: var(--primary-light);
    color: var(--primary-hover);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Department Colors */
.dept-예배위원회 { background-color: #e0e7ff; color: #4338ca; }
.dept-교육위원회 { background-color: #dcfce7; color: #15803d; }
.dept-친교위원회 { background-color: #fef08a; color: #a16207; }
.dept-선교위원회 { background-color: #ffe4e6; color: #be123c; }
.dept-재정위원회 { background-color: #f3e8ff; color: #7e22ce; }
.dept-청년부 { background-color: #e0f2fe; color: #0369a1; }
.dept-학생부 { background-color: #ffedd5; color: #c2410c; }
.dept-아동부 { background-color: #fce7f3; color: #be185d; }

/* Department & Location View */
.department-section,
.location-section {
    height: 100%;
}

.department-list-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.department-item {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.2s;
    border-left: 4px solid var(--border);
}

.department-item:hover {
    box-shadow: var(--shadow-sm);
}

.dept-item-info h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.dept-item-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.dept-item-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.filter-select {
    width: 100%;
    max-width: 300px;
}

/* Form */
.registration-section {
    height: fit-content;
}

#event-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

input, select, textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-main);
    background-color: var(--surface);
    transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.time-select option:disabled {
    color: var(--danger);
    background-color: var(--background);
}

/* Buttons */
.btn {
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--background);
}

.btn-block {
    width: 100%;
    padding: 0.75rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.25rem;
    margin-top: 0.125rem;
}

.alert-warning {
    background-color: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-content p {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--text-main);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

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

.toast i {
    color: var(--success);
    font-size: 1.25rem;
}

/* Logo */
.church-logo {
    max-width: 100%;
    height: auto;
    max-height: 48px;
    object-fit: contain;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background-color: var(--surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

/* Admin Styles */
.admin-section {
    height: 100%;
    overflow-y: auto;
}

.admin-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-panel {
    background-color: var(--background);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.admin-panel h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.add-dept-form, .password-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.org-manage-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.org-committee-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

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

.org-committee-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--primary);
}

.org-dept-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.org-dept-item {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.org-dept-item button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    display: flex;
    align-items: center;
}

.org-dept-item button:hover {
    color: var(--danger);
}

.add-dept-inline-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.add-dept-inline-form input {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    flex: 1;
}

.add-dept-inline-form button {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-danger {
    background-color: transparent;
    color: var(--danger);
    border: 1px solid var(--danger-light);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
}

/* Form Utilities */
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block !important;
    opacity: 1;
}

/* Event Dots (Mobile Calendar) */
.event-dot-container {
    display: none;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
    justify-content: center;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .content-grid {
        flex-direction: column;
    }
    .registration-section {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.open {
        left: 0;
    }

    .mobile-menu-btn {
        display: flex !important;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Mobile Calendar Settings */
    .calendar-section {
        overflow-x: hidden;
    }
    
    .calendar-header {
        min-width: 100%;
        font-size: 0.8rem;
    }
    
    .calendar-body {
        min-width: 100%;
    }
    
    .calendar-day {
        padding: 0.25rem;
        min-height: 80px;
    }
    
    .event-tag {
        display: none !important;
    }
    
    .event-dot-container {
        display: flex;
    }
    
    .content-grid {
        padding: 1rem;
    }
    
    .month-navigation {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .month-navigation h3 {
        min-width: auto;
    }
    
    .filter-select {
        max-width: 100%;
        margin-left: 0 !important;
        margin-top: 0.5rem;
    }
}

/* Calendar Swipe Animations */
@keyframes slide-left-anim {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-right-anim {
    from { transform: translateX(-30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.slide-left {
    animation: slide-left-anim 0.3s ease-out;
}

.slide-right {
    animation: slide-right-anim 0.3s ease-out;
}
