/**
 * Zipper Theme - Main Layout Stylesheet
 *
 * @package Zipper
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    /* Colors - Premium Gold Theme */
    --color-bg: #ffffff;
    --color-bg-secondary: #faf9f7;
    --color-text: #2d2a26;
    --color-text-muted: #8c8579;
    --color-text-dark: #1a1816;
    --color-border: #e8e4dc;
    --color-accent: #d4af37;
    --color-accent-hover: #b8860b;
    --color-accent-light: rgba(212, 175, 55, 0.1);
    --color-gold-gradient: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 56px;

    /* Layout */
    --content-max-width: 1200px;
    --content-sidebar-width: 340px; /* 300px 광고 + 40px 패딩 */
    --header-height: 56px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-base: 15px;
    --line-height-base: 1.6;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: var(--line-height-base);
    color: var(--color-text);
    background-color: var(--color-bg);
}

/* ==========================================================================
   Main Layout Structure
   ========================================================================== */

/* Site Container */
.site {
    display: flex;
    min-height: 100vh;
}

/* Main Content Wrapper (Right of sidebar) */
.site-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* When sidebar is collapsed */
body.sidebar-collapsed .site-content-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* ==========================================================================
   Content Header (How to, Share buttons)
   ========================================================================== */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: calc(var(--header-height) + 6px);
    padding: 0 var(--spacing-lg);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-icon i {
    font-size: 16px;
}

#favoriteToolBtn {
    padding: 8px 10px;
}

#favoriteToolBtn i {
    color: #9ca3af;
    transition: color 0.2s;
}

#favoriteToolBtn.active i {
    color: #fbbf24;
}

/* Language Switcher */
.lang-switcher {
    position: relative;
}

.lang-switcher .btn-icon {
    gap: 4px;
}

.lang-arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.lang-switcher.is-open .lang-arrow {
    transform: rotate(180deg);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 200;
}

.lang-switcher.is-open .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px 14px;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.15s;
}

.lang-option:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.lang-option:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.lang-option:hover {
    background: var(--color-bg-secondary);
}

.lang-option.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--color-accent);
}

.lang-flag {
    font-size: 16px;
}

/* ==========================================================================
   Notification Dropdown (알림)
   ========================================================================== */
.notification-wrapper {
    position: relative;
}

#notificationBtn {
    position: relative;
    padding: 8px 10px;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    display: none;
}

.notification-badge.has-new {
    display: block;
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 300;
    overflow: hidden;
}

.notification-wrapper.is-open .notification-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
}

.notification-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-dark);
}

.notification-list {
    max-height: 360px;
    overflow-y: auto;
}

.notification-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--color-text-muted);
    font-size: 13px;
}

.notification-loading i {
    animation: spin 1s linear infinite;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.15s;
}

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

.notification-item:hover {
    background: var(--color-bg-secondary);
}

.notification-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-gold-gradient);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 16px;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-tool-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-dark);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.notification-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: rgba(212, 175, 55, 0.12);
    border-radius: 4px;
    color: var(--color-accent-hover);
    font-size: 11px;
    font-weight: 500;
}

.notification-time {
    color: var(--color-text-muted);
}

.notification-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    color: var(--color-text-muted);
    text-align: center;
}

.notification-empty i {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.notification-empty span {
    font-size: 13px;
}

.notification-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.notification-footer button {
    width: 100%;
    padding: 10px 16px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s;
}

.notification-footer button:hover {
    background: var(--color-border);
}

@media (max-width: 480px) {
    .notification-dropdown {
        position: fixed;
        top: calc(var(--header-height) + 8px);
        left: 16px;
        right: 16px;
        width: auto;
    }
}

/* ==========================================================================
   Content Body (Main + Right Sidebar)
   ========================================================================== */
.content-body {
    display: flex;
    flex: 1;
    width: 100%;
    max-width: 100%;
}

.content-main {
    flex: 1;
    min-width: 0;
    padding: var(--spacing-xl);
    overflow-x: hidden;
}

/* ==========================================================================
   Right Sidebar (TOC + Ads)
   ========================================================================== */
.content-sidebar {
    width: var(--content-sidebar-width);
    flex-shrink: 0;
    padding: var(--spacing-xl) 20px;
    border-left: 1px solid var(--color-border);
}

.sidebar-sticky-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* TOC Container */
.toc-container {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

.toc-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 var(--spacing-sm);
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc-link {
    display: block;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.toc-link:hover {
    color: var(--color-accent);
    background: rgba(212, 175, 55, 0.08);
}

.toc-link.active {
    color: var(--color-accent);
    background: rgba(212, 175, 55, 0.12);
    font-weight: 500;
}

.toc-link.toc-sub {
    padding-left: 24px;
    font-size: 12px;
}

/* ==========================================================================
   Site Footer (100% width)
   ========================================================================== */
.site-footer {
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    padding: var(--spacing-xl);
    margin-top: auto;
}

.footer-inner {
    width: 100%;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.footer-brand {
    max-width: 280px;
}

.footer-logo {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-dark);
    text-decoration: none;
}

.footer-logo i {
    font-size: 24px;
    color: var(--color-accent);
}

.footer-logo-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.footer-tagline {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    margin: var(--spacing-sm) 0 var(--spacing-xs);
}

.footer-description {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.6;
}

.footer-links {
    display: flex;
    gap: 48px;
}

.footer-column h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 var(--spacing-md);
}

.footer-column ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-column li {
    margin-bottom: 10px;
}

.footer-column a {
    font-size: 14px;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-column a:hover {
    color: var(--color-accent);
}

.footer-bottom {
    padding-top: var(--spacing-lg);
    text-align: center;
}

.footer-bottom p {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0;
}

/* ==========================================================================
   Ad Placeholders
   ========================================================================== */
.ad-container {
    margin: var(--spacing-lg) 0;
}

.ad-horizontal {
    display: flex;
    justify-content: center;
}

.ad-placeholder {
    background: var(--color-bg-secondary);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

/* 본문 가로 광고 (728x90) */
.ad-horizontal .ad-placeholder {
    width: 728px;
    height: 90px;
}

/* 사이드바 광고 (300x250) */
.ad-sidebar {
    width: 300px;
    min-height: 250px;
}

.ad-sidebar .ad-placeholder {
    width: 300px;
    height: 250px;
}

/* 사이드바 대형 광고 (300x600) */
.ad-sidebar-large {
    width: 300px;
    min-height: 600px;
}

.ad-sidebar-large .ad-placeholder {
    width: 300px;
    height: 600px;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 1200px) {
    /* 1200px 이하: 오른쪽 사이드바 숨김 (300x250 광고 유지 불가) */
    .content-sidebar {
        display: none;
    }

    .content-main {
        padding: var(--spacing-lg);
    }

    .ad-horizontal .ad-placeholder {
        width: 100%;
        max-width: 728px;
        height: 90px;
    }
}

@media (max-width: 1024px) {
    .content-main {
        padding: var(--spacing-lg) var(--spacing-md);
    }
}

@media (max-width: 768px) {
    .site-content-wrapper {
        margin-left: 0;
    }

    body.sidebar-collapsed .site-content-wrapper {
        margin-left: 0;
    }

    .content-header {
        padding: 0 var(--spacing-md);
    }

    .btn-icon span {
        display: none;
    }

    .btn-icon {
        padding: 8px;
    }

    .footer-content {
        flex-direction: column;
        gap: var(--spacing-lg);
    }

    .footer-brand {
        max-width: 100%;
    }

    .footer-links {
        flex-wrap: wrap;
        gap: var(--spacing-lg);
    }

    .footer-column {
        min-width: 140px;
    }
}

/* ==========================================================================
   Contact Modal
   ========================================================================== */
.contact-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: var(--spacing-md);
}

.contact-modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.contact-modal {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.contact-modal-overlay.is-open .contact-modal {
    transform: translateY(0);
}

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

.contact-modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-dark);
}

.contact-modal-header h3 i {
    color: var(--color-accent);
}

.contact-modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.contact-modal-close:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.contact-modal-form {
    padding: var(--spacing-lg);
}

.contact-form-group {
    margin-bottom: var(--spacing-md);
}

.contact-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-dark);
    margin-bottom: 6px;
}

.contact-form-group label .required {
    color: #ef4444;
}

.contact-form-group input[type="text"],
.contact-form-group input[type="email"],
.contact-form-group input[type="number"],
.contact-form-group select,
.contact-form-group textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text-dark);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.contact-form-group input:focus,
.contact-form-group select:focus,
.contact-form-group textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.contact-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.contact-form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238c8579' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

/* Captcha */
.contact-captcha .captcha-question {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-captcha .captcha-question span {
    flex-shrink: 0;
    padding: 12px 16px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-dark);
}

.contact-captcha .captcha-question input {
    width: 100px;
}

/* Form Actions */
.contact-form-actions {
    display: flex;
    gap: 10px;
    margin-top: var(--spacing-lg);
}

.contact-btn-cancel {
    flex: 1;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.contact-btn-cancel:hover {
    background: var(--color-border);
}

.contact-btn-submit {
    flex: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--color-gold-gradient);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.contact-btn-submit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.contact-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Form Message */
.contact-form-message {
    margin-top: var(--spacing-md);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: none;
}

.contact-form-message.success {
    display: block;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #22c55e;
    color: #16a34a;
}

.contact-form-message.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #dc2626;
}

/* Responsive */
@media (max-width: 480px) {
    .contact-modal {
        max-height: 100vh;
        border-radius: 0;
    }

    .contact-form-actions {
        flex-direction: column;
    }

    .contact-btn-cancel,
    .contact-btn-submit {
        flex: none;
        width: 100%;
    }

    .contact-captcha .captcha-question {
        flex-wrap: wrap;
    }

    .contact-captcha .captcha-question input {
        width: 100%;
    }
}
