/**
 * Mobile App Style - 모바일 앱 스타일 CSS
 * 직관적이고 쉬운 사용자 경험
 */

/* ===== 기본 레이아웃 ===== */
.app-main {
    padding-bottom: 80px; /* 하단 네비 공간 */
    min-height: 100vh;
}

/* ===== 검색 섹션 ===== */
.search-section {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.search-container {
    position: relative;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    width: 24px;
    height: 24px;
    border: none;
    background: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 4px;
}

.search-clear svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-lg);
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item:active {
    background: var(--bg-dark);
}

.result-name {
    color: var(--text-primary);
    font-weight: 500;
}

.result-usage {
    color: var(--text-muted);
    font-size: 13px;
}

.search-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

/* ===== 빠른 실행 도구 ===== */
.quick-section {
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.quick-section::-webkit-scrollbar {
    display: none;
}

.quick-tools {
    display: flex;
    gap: 12px;
    padding-bottom: 4px;
}

.quick-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    text-decoration: none;
    min-width: 72px;
    transition: all 0.2s ease;
}

.quick-tool:hover,
.quick-tool:active {
    transform: scale(0.95);
    border-color: var(--tool-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.quick-icon {
    font-size: 28px;
    line-height: 1;
}

.quick-name {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

/* ===== 실시간 배너 ===== */
.live-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    margin: 0 16px;
    border-radius: 12px;
}

.live-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.live-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.live-label {
    font-size: 12px;
    color: var(--text-muted);
}

.live-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
}

/* ===== 광고 슬롯 ===== */
.ad-slot {
    margin: 16px;
    border-radius: 12px;
    overflow: hidden;
}

.ad-placeholder {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-dark));
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.ad-native {
    min-height: 100px;
}

.ad-infeed {
    min-height: 120px;
}

/* ===== 섹션 블록 ===== */
.section-block {
    padding: 20px 16px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.section-badge {
    font-size: 11px;
    padding: 4px 8px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-radius: 20px;
    font-weight: 600;
}

.section-link {
    font-size: 14px;
    color: var(--primary-light);
    text-decoration: none;
}

/* ===== 도구 리스트 (가로 스크롤) ===== */
.tool-list.horizontal {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tool-list.horizontal::-webkit-scrollbar {
    display: none;
}

.tool-card-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    min-width: 180px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.tool-card-compact:hover,
.tool-card-compact:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.tool-rank {
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.tool-card-compact:nth-child(1) .tool-rank {
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
}

.tool-card-compact:nth-child(2) .tool-rank {
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
}

.tool-card-compact:nth-child(3) .tool-rank {
    background: linear-gradient(135deg, #fbbf24, #b45309);
}

.tool-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.tool-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tool-info .tool-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-info .tool-usage {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== 최근 사용 ===== */
.recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recent-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    text-decoration: none;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.recent-item:hover,
.recent-item:active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.recent-item svg {
    color: var(--text-muted);
}

.recent-item:hover svg,
.recent-item:active svg {
    color: white;
}

/* ===== 카테고리 그리드 ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

@media (max-width: 480px) {
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.cat-card:hover,
.cat-card:active {
    transform: scale(0.95);
    border-color: var(--cat-color);
}

.cat-icon {
    font-size: 24px;
}

.cat-name {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    text-align: center;
}

/* ===== 인라인 도구 ===== */
.inline-tool {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
}

.inline-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.range-inputs {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.range-inputs input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 16px;
    text-align: center;
    min-width: 0;
}

.range-sep {
    color: var(--text-muted);
    font-weight: 500;
}

.btn-pick {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.inline-result {
    text-align: center;
    padding: 24px;
    background: var(--bg-dark);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.inline-result .result-number {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.inline-result.picking .result-number {
    animation: picking 0.1s linear infinite;
}

.inline-result.done .result-number {
    animation: pop 0.3s ease;
}

@keyframes picking {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ===== 추천 카드 ===== */
.recommend-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 400px) {
    .recommend-list {
        grid-template-columns: 1fr;
    }
}

.recommend-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-dark));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.recommend-card:hover,
.recommend-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.rec-visual {
    font-size: 36px;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border-radius: 12px;
    flex-shrink: 0;
}

.rec-content h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.rec-content p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

/* ===== 모바일 하단 네비게이션 ===== */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

.nav-item span {
    font-size: 10px;
    font-weight: 500;
}

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

.nav-main {
    position: relative;
}

.nav-main-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -24px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.nav-main-btn svg {
    width: 24px;
    height: 24px;
    color: white;
}

.nav-main span {
    margin-top: 4px;
}

/* ===== 빠른 뽑기 모달 ===== */
.quick-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.quick-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: var(--bg-card);
    border-radius: 24px 24px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

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

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.modal-close svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.quick-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.quick-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-opt:active {
    transform: scale(0.95);
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.opt-icon {
    font-size: 32px;
}

.opt-name {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.quick-result {
    min-height: 100px;
    background: var(--bg-dark);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quick-result.show {
    opacity: 1;
}

.qr-number {
    font-size: 64px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pop 0.3s ease;
}

.qr-text {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    animation: pop 0.3s ease;
}

.qr-dice {
    font-size: 72px;
    animation: pop 0.3s ease;
}

.qr-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ===== 데스크톱 조정 ===== */
@media (min-width: 768px) {
    .app-main {
        max-width: 600px;
        margin: 0 auto;
        padding-bottom: 100px;
    }

    .mobile-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 24px 24px 0 0;
    }

    .search-section {
        padding: 16px 20px;
    }

    .quick-tools {
        justify-content: center;
    }

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

/* ===== 다크모드 조정 ===== */
@media (prefers-color-scheme: light) {
    .search-box {
        background: #f8fafc;
    }

    .live-banner {
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
    }
}

/* ===== 미니멀 헤더 (홈) ===== */
.site-header.minimal {
    padding: 12px 0;
    background: transparent;
    border-bottom: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

.header-minimal {
    display: flex;
    justify-content: center;
}

.site-logo-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 18px;
}

.site-logo-mini .logo-icon {
    font-size: 24px;
}

/* 홈 페이지 조정 */
body.home .site-main {
    padding-top: 0;
}

body.home {
    background: var(--bg-primary);
}

/* 홈 이외 페이지에서 모바일 네비 숨김 */
body:not(.home) .mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    body:not(.home) .mobile-nav {
        display: flex;
    }

    body:not(.home) .app-main,
    body:not(.home) .site-main {
        padding-bottom: 80px;
    }
}
