@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

:root {
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --chat-bg: #f1f5f9;
    --bubble-me: #6366f1;
    --bubble-me-text: #ffffff;
    --bubble-you: #ffffff;
    --bubble-you-text: #1e293b;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --nav-bg: rgba(255, 255, 255, 0.8);
    --header-height: 60px;
    --nav-height: 70px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --chat-bg: #0f172a;
    --bubble-me: #6366f1;
    --bubble-you: #334155;
    --bubble-you-text: #f1f5f9;
    --nav-bg: rgba(30, 41, 59, 0.8);
}

* { 
    margin: 0; padding: 0; box-sizing: border-box; 
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body { 
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
.app-container { 
    width: 100%;
    max-width: 500px; 
    height: 100vh;
    background: var(--bg-color);
    position: relative; 
    overflow: hidden; 
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
/* Responsive Layout */
@media (min-width: 1024px) {
    .app-container {
        max-width: 450px;
        height: 92vh;
        border-radius: 32px;
        margin: 20px;
        border: 1px solid var(--border-color);
    }
}

@media (min-width: 600px) and (max-width: 1023px) {
    .app-container {
        max-width: 600px;
        height: 100vh;
        border-radius: 0;
    }
}

@media (max-width: 599px) {
    .app-container {
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
    }
}

/* Header */
.app-header { 
    height: var(--header-height);
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 { 
    font-size: 1.25rem; 
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 15px;
}

.header-actions i { 
    font-size: 1.2rem; 
    cursor: pointer; 
    color: var(--text-muted); 
    transition: color 0.2s, transform 0.2s;
}

.header-actions i:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

/* Main Content */
.app-main { 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden;
    background: var(--bg-color);
    padding-bottom: 20px;
}

.tab-content { display: none; animation: fadeIn 0.3s ease-out; }
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Section Title */
.section-title { 
    padding: 15px 20px 10px; 
    font-size: 0.75rem; 
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted); 
}

/* Lists */
.list-item { 
    display: flex; 
    align-items: center; 
    padding: 12px 20px; 
    cursor: pointer; 
    transition: background 0.2s; 
}

.list-item:hover { 
    background: rgba(99, 102, 241, 0.05); 
}

.avatar { 
    width: 52px; 
    height: 52px; 
    border-radius: 20px; 
    object-fit: cover; 
    margin-right: 15px; 
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.info { flex: 1; min-width: 0; }
.info .name { font-weight: 700; font-size: 1rem; color: var(--text-main); margin-bottom: 2px; }
.info .status { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* My Profile Card */
.my-profile-card { 
    display: flex; 
    align-items: center; 
    padding: 24px 20px; 
    background: linear-gradient(to bottom, rgba(99, 102, 241, 0.05), transparent);
}

.my-profile-card .avatar { width: 64px; height: 64px; border-radius: 24px; }
.my-profile-card .name { font-weight: 800; font-size: 1.25rem; }
.badge { background: #ef4444; color: white; font-size: 0.7rem; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(239, 68, 68, 0.4); }

/* Bottom Nav */
.bottom-nav { 
    display: flex; 
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color); 
    height: var(--nav-height); 
    padding-bottom: env(safe-area-inset-bottom); 
}

.nav-item { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    color: var(--text-muted); 
    cursor: pointer; 
    transition: all 0.2s;
    position: relative;
}

.nav-item i { font-size: 1.4rem; margin-bottom: 4px; }
.nav-item span { font-size: 0.7rem; font-weight: 700; }
.nav-item.active { color: var(--primary-color); }
.nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 0 0 4px 4px;
}

/* Chat View */
.chat-view { 
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    background: var(--chat-bg); 
    z-index: 200; 
    display: flex;
    flex-direction: column; 
    overflow-x: hidden;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.chat-header { 
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0 20px; 
    height: var(--header-height);
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    border-bottom: 1px solid var(--border-color);
}

.chat-header h2 { font-size: 1.1rem; font-weight: 700; }

.message-area { 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden;
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
}

.msg { display: flex; flex-direction: column; }
.msg-out { align-items: flex-end; }
.msg-in { align-items: flex-start; }

.msg-content-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}
.period-badge-inline {
    background: rgba(0,0,0,0.05);
    color: var(--text-main);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--border-color);
}
.period-badge-inline.expired {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: #ef4444;
}

.period-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    backdrop-filter: blur(4px);
    font-weight: 800;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.period-badge.expired {
    background: rgba(239, 68, 68, 0.8);
}

.unread-mark {
    font-size: 0.65rem;
    color: #facc15; /* Yellowish for unread mark */
    font-weight: 800;
    margin-bottom: 2px;
}

.bubble { 
    max-width: var(--bubble-max-width, 280px); 
    padding: 10px 14px; 
    border-radius: 20px; 
    font-size: 0.95rem; 
    line-height: 1.5; 
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.bubble-img {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: hidden;
}
.bubble-emoticon {
    padding: 4px 8px !important;
    background: transparent !important;
    box-shadow: none !important;
}

.emo-tab {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.emo-tab:active { transform: scale(0.95); }
.emo-tab.active {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.chat-img {
    border: none !important;
    display: block;
}

.msg-out .bubble { 
    background: var(--bubble-me); 
    color: var(--bubble-me-text); 
    border-bottom-right-radius: 4px; 
}

.msg-in .bubble { 
    background: var(--bubble-you); 
    color: var(--bubble-you-text); 
    border-bottom-left-radius: 4px; 
}

.msg-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Chat Input */
.chat-input-wrapper { 
    background: var(--card-bg); 
    display: flex; 
    align-items: center; 
    padding: 12px 16px; 
    gap: 12px; 
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper input { 
    flex: 1; 
    border: none; 
    background: var(--chat-bg); 
    padding: 12px 18px; 
    border-radius: 24px; 
    outline: none; 
    font-size: 0.95rem;
    color: var(--text-main);
}

.chat-input-wrapper button { 
    background: var(--primary-color); 
    color: white;
    border: none; 
    width: 44px; 
    height: 44px; 
    border-radius: 22px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: transform 0.2s, background 0.2s;
}

.chat-input-wrapper button:hover {
    background: var(--primary-dark);
    transform: rotate(15deg) scale(1.05);
}

/* Modals */
.modal { 
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    background: rgba(0,0,0,0.4); 
    backdrop-filter: blur(4px);
    z-index: 200; 
    display: flex;
    align-items: center; 
    justify-content: center; 
    padding: 20px;
}

.modal-content { 
    background: var(--card-bg); 
    width: 100%;
    max-width: 350px;
    border-radius: 28px; 
    overflow: hidden; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

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

.modal-header .close {
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-header .close:hover {
    color: var(--danger);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Buttons */
.btn-primary { 
    background: var(--primary-color); 
    color: white; 
    border: none; 
    padding: 14px; 
    border-radius: var(--radius-md); 
    font-weight: 700; 
    cursor: pointer; 
    transition: opacity 0.2s;
}

.btn-primary:active { opacity: 0.8; }

/* Forms & Auth Pages */
.auth-container {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    padding: 40px 32px;
    border-radius: 32px;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease-out;
}

.auth-card h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-color), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-card p.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 32px;
}

.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    margin-left: 4px;
}

.input-group input, .input-group textarea {
    width: 100%;
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    padding: 14px 18px;
    border-radius: 16px;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus, .input-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.btn-auth {
    width: 100%;
    padding: 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.btn-auth:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-auth:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-footer {
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
}

/* Typing Indicator */
.typing-indicator {
    padding: 10px 20px;
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
    display: none;
}

/* Board Items */
.board-item {
    background: var(--card-bg);
    margin: 16px;
    padding: 24px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}
.board-item:active {
    transform: scale(0.98);
}

.stat-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Extra Menu Grid */
.chat-extra-menu {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 24px;
    gap: 20px;
    background: var(--card-bg);
    border-radius: 32px 32px 0 0;
    box-shadow: 0 -10px 25px rgba(0,0,0,0.05);
}

.extra-item .icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 20px;
    background: var(--chat-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.2s;
}

.extra-item:hover .icon-circle {
    background: var(--primary-color);
    color: white !important;
    transform: translateY(-4px);
}

/* Terms styling */
.terms-box {
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    height: 100px;
    overflow-y: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Empty State Styling */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.7;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 600;
}

/* Sync List & Selection */
.sync-list-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}
.sync-list-item:hover {
    background: var(--chat-bg);
}
.sync-list-item .avatar {
    width: 44px;
    height: 44px;
    margin: 0;
}
.sync-list-item .user-info {
    flex: 1;
}
.sync-list-item .user-info .name {
    font-weight: 700;
    font-size: 0.95rem;
}
.sync-list-item .user-info .username {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.custom-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.custom-checkbox i {
    font-size: 0.8rem;
    color: white;
    display: none;
}
.custom-checkbox.checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}
.custom-checkbox.checked i {
    display: block;
}

.sync-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--nav-bg);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
/* Chat Menu Overlay */
.chat-menu-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: none;
    justify-content: flex-end;
    animation: fadeIn 0.3s ease-out;
}

.chat-menu-content {
    width: 75%;
    max-width: 300px;
    height: 100%;
    background: var(--card-bg);
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    animation: slideFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideFromRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.menu-header {
    padding: 24px 20px;
    font-size: 1.1rem;
    font-weight: 800;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.menu-list {
    flex: 1;
    padding: 12px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-main);
}

.menu-item:hover {
    background: rgba(99, 102, 241, 0.05);
}

.menu-item i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    color: var(--text-muted);
}

.menu-item:hover i {
    color: var(--primary-color);
}

.menu-item.danger {
    color: var(--danger);
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.menu-item.danger i {
    color: var(--danger);
}
.bubble-call {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.bubble-call i {
    color: white;
}

/* Action Button (Friend Menu) */
.action-btn {
    width: 100%;
    padding: 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.action-btn i {
    margin-right: 10px;
    font-size: 1.1rem;
}

/* Search Input (Backup Management) */
.search-input {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 8px 16px;
    border-radius: 12px;
    outline: none;
    font-size: 0.9rem;
    width: 200px;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: #6366f1;
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Delete Button Style */
.btn-del {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-del:hover {
    background: #ef4444;
    color: white;
}

/* Friend Management More Button */
.friend-more-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.friend-more-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary-color) !important;
}

[data-theme="dark"] .friend-more-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.friend-more-btn i {
    transition: transform 0.2s;
}

.friend-more-btn:active i {
    transform: scale(0.8);
}
