/* ============================================
   Portal Layout Styles
   - 사이드바 네비게이션
   - 헤더
   - 반응형 레이아웃
   ============================================ */

/* CSS Variables - 핑크 테마 */
:root {
    --primary: #f9a8d4;
    --primary-dark: #ec4899;
    --primary-light: #fdf2f8;
    --accent: #db2777;
    --background: #fafafa;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    --header-height: 60px;
    --transition-speed: 0.3s;

    /* Font Sizes - Desktop */
    --font-title: 1.5rem;
    --font-section: 1.25rem;
    --font-card-title: 1rem;
    --font-body: 0.9rem;
    --font-small: 0.8rem;
    --font-caption: 0.75rem;
    --font-button: 0.875rem;
    --font-input: 0.875rem;
}

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

body.portal-layout {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   Portal Container
   ============================================ */
.portal-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition-speed) ease, width var(--transition-speed) ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.sidebar-logo-text {
    font-size: var(--font-card-title);
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-logo-text span {
    color: var(--accent);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    padding: 8px 20px;
    font-size: var(--font-caption);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    gap: 12px;
}

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

.nav-item.active {
    background: var(--primary-light);
    color: var(--accent);
    border-left-color: var(--primary-dark);
    font-weight: 500;
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.nav-item-text {
    font-size: var(--font-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item-badge {
    margin-left: auto;
    background: var(--primary);
    color: var(--text-primary);
    font-size: var(--font-caption);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sidebar-user:hover {
    background: var(--primary-light);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: var(--font-body);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: var(--font-small);
    color: var(--text-secondary);
}

/* ============================================
   Main Content Area
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed) ease;
}

/* Header */
.main-header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease;
}

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

.hamburger-btn svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

.page-title {
    font-size: var(--font-section);
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
}

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

.header-btn-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--primary-light);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.header-user:hover {
    background: var(--primary);
}

.header-user-avatar {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.header-user-name {
    font-size: var(--font-body);
    font-weight: 500;
    color: var(--text-primary);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 24px;
    overflow: visible;
}

/* Page Container */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* ============================================
   Mobile Sidebar Overlay
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ============================================
   Responsive - Tablet (768px ~ 1024px)
   ============================================ */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar-logo-text,
    .nav-section-title,
    .nav-item-text,
    .nav-item-badge,
    .sidebar-user-info {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 14px;
    }

    .nav-item-icon {
        width: 24px;
        height: 24px;
        font-size: 20px;
    }

    .sidebar-user {
        justify-content: center;
    }

    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    /* Expand on hover */
    .sidebar:hover {
        width: var(--sidebar-width);
    }

    .sidebar:hover .sidebar-logo-text,
    .sidebar:hover .nav-section-title,
    .sidebar:hover .nav-item-text,
    .sidebar:hover .nav-item-badge,
    .sidebar:hover .sidebar-user-info {
        display: block;
    }

    .sidebar:hover .nav-item {
        justify-content: flex-start;
        padding: 12px 20px;
    }

    .sidebar:hover .nav-item-icon {
        width: 20px;
        height: 20px;
        font-size: 16px;
    }

    .sidebar:hover .sidebar-user {
        justify-content: flex-start;
    }
}

/* ============================================
   Responsive - Mobile (< 768px)
   ============================================ */
@media (max-width: 768px) {
    :root {
        --font-title: 1.25rem;
        --font-section: 1.1rem;
        --font-card-title: 0.95rem;
        --font-body: 0.85rem;
        --font-small: 0.75rem;
        --font-caption: 0.7rem;
        --font-button: 0.8rem;
        --font-input: 0.85rem;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.active {
        pointer-events: auto;
    }

    .main-content {
        margin-left: 0;
    }

    .portal-layout .hamburger-btn {
        display: flex;
    }

    .main-header {
        padding: 0 16px;
    }

    .content-area {
        padding: 12px;
        max-width: 100vw;
        overflow: visible;
    }

    .page-title {
        font-size: 16px;
    }

    .header-user-name {
        display: none;
    }

    /* 모든 페이지 공통 모바일 너비 통일 */
    .page {
        max-width: 100%;
        overflow: visible;
        box-sizing: border-box;
    }

    .page > * {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* 카드/섹션 공통 */
    .card,
    .section-header,
    .form-group {
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* ============================================
   Common UI Components
   ============================================ */

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

.card-title {
    font-size: var(--font-card-title);
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: var(--font-button);
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-text {
    background: none;
    color: var(--accent);
    padding: 8px 12px;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: var(--font-small);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

/* Links */
.link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.link:hover {
    color: var(--primary-dark);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: var(--font-small);
    font-weight: 500;
    border-radius: 20px;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--accent);
}

.badge-success {
    background: #d1fae5;
    color: #059669;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-error {
    background: #fee2e2;
    color: #dc2626;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-section);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: var(--font-body);
    margin-bottom: 24px;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-dark);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Logout Button */
.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 12px;
}

.logout-btn:hover {
    background: #fee2e2;
    border-color: var(--error);
    color: var(--error);
}

/* ============================================
   Responsive - Wide screens (1440px+)
   ============================================ */
@media (min-width: 1440px) {
    .content-area {
        padding: 32px 40px;
    }
}

/* ============================================
   Responsive - Small phones (< 480px)
   ============================================ */
@media (max-width: 480px) {
    .content-area {
        padding: 8px;
    }

    .main-header {
        padding: 0 12px;
        height: 50px;
    }

    .page-title {
        font-size: 14px;
    }

    .card-body {
        padding: 12px;
    }

    .card-header {
        padding: 12px 14px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .sidebar.open {
        width: 260px;
    }
}
