/* ═══════════════════════════════════════════════════════════
   진삼국무쌍5 에디터 - Style System
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables / Design Tokens ── */
:root {
    /* Core Palette */
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --text: #212529;
    --text-secondary: #6C757D;
    --primary: #0D6EFD;
    --primary-hover: #0B5ED7;
    --primary-light: rgba(13, 110, 253, 0.08);
    --primary-border: rgba(13, 110, 253, 0.25);

    /* Accent Colors */
    --success: #198754;
    --success-hover: #157347;
    --success-light: rgba(25, 135, 84, 0.08);
    --warning: #FFC107;
    --warning-hover: #E0A800;
    --warning-text: #664D03;
    --danger: #DC3545;
    --danger-hover: #BB2D3B;
    --danger-light: rgba(220, 53, 69, 0.08);
    --accent: #6F42C1;
    --accent-hover: #5A32A3;

    /* Element Colors */
    --fire: #E8590C;
    --fire-bg: rgba(232, 89, 12, 0.08);
    --fire-border: rgba(232, 89, 12, 0.3);
    --ice: #1C7ED6;
    --ice-bg: rgba(28, 126, 214, 0.08);
    --ice-border: rgba(28, 126, 214, 0.3);
    --thunder: #F59F00;
    --thunder-bg: rgba(245, 159, 0, 0.08);
    --thunder-border: rgba(245, 159, 0, 0.3);

    /* Layout */
    --border: #DEE2E6;
    --border-light: #E9ECEF;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3 {
    line-height: 1.3;
}

code {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* ── Header ── */
#app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-icon {
    font-size: 28px;
    color: var(--primary);
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-author {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ── Main ── */
#app-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

/* ── Tab Navigation ── */
#tab-nav {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 5px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
    position: relative;
}

.tab-btn .material-symbols-outlined {
    font-size: 20px;
}

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

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
}

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

/* ── Tab Panels ── */
.tab-panel {
    display: none;
    animation: fadeSlideIn 0.35s ease;
}

.tab-panel.active {
    display: block;
}

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

/* ── Panel Card ── */
.panel-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--primary-light);
}

.card-header .material-symbols-outlined {
    font-size: 26px;
    color: var(--primary);
}

.card-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

/* ── Tab 1: File Select ── */
.file-select-card {
    min-height: 260px;
}

.file-info-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 24px;
}

.file-info-box .material-symbols-outlined {
    color: var(--primary);
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 2px;
}

.file-info-box p {
    font-size: 0.87rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.file-input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.file-name-display {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    transition: all var(--transition);
    min-height: 48px;
}

.file-name-display .material-symbols-outlined {
    color: var(--text-secondary);
    font-size: 22px;
}

.file-name-display.has-file {
    border-color: var(--primary-border);
    border-style: solid;
    background: var(--primary-light);
}

.file-name-display.has-file .material-symbols-outlined {
    color: var(--primary);
}

#file-name-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.file-name-display.has-file #file-name-text {
    color: var(--text);
    font-weight: 500;
}

.file-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--success-light);
    color: var(--success);
    font-size: 0.87rem;
    font-weight: 500;
}

.file-status .status-icon {
    font-size: 20px;
}

.file-status.error {
    background: var(--danger-light);
    color: var(--danger);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.87rem;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn .material-symbols-outlined {
    font-size: 18px;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    transition: background var(--transition);
}

.btn:active::after {
    background: rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: var(--success-hover);
    box-shadow: 0 2px 8px rgba(25, 135, 84, 0.3);
}

.btn-warning {
    background: var(--warning);
    color: var(--warning-text);
}
.btn-warning:hover {
    background: var(--warning-hover);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: var(--danger-hover);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(111, 66, 193, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-large {
    padding: 12px 24px;
    font-size: 0.93rem;
}

/* ── Warrior Controls ── */
.warrior-controls {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.select-input {
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236C757D' d='M6 8.5L1 3.5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: all var(--transition);
    min-width: 140px;
}

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

.select-input:hover {
    border-color: var(--primary);
}

/* ── Section Subtitles ── */
.section-subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.93rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}

.section-subtitle .material-symbols-outlined {
    font-size: 20px;
    color: var(--primary);
}

/* ── Radio Group (Element Select) ── */
.element-select-section {
    margin-bottom: 24px;
}

.radio-group {
    display: flex;
    gap: 10px;
}

.radio-card {
    flex: 1;
    cursor: pointer;
}

.radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg);
    transition: all var(--transition);
}

.radio-visual .material-symbols-outlined {
    font-size: 20px;
}

.radio-card:hover .radio-visual {
    border-color: var(--text-secondary);
}

/* Fire checked */
.radio-card input[type="radio"]:checked ~ .radio-visual.fire {
    background: var(--fire-bg);
    border-color: var(--fire-border);
    color: var(--fire);
    box-shadow: 0 2px 8px rgba(232, 89, 12, 0.15);
}

/* Ice checked */
.radio-card input[type="radio"]:checked ~ .radio-visual.ice {
    background: var(--ice-bg);
    border-color: var(--ice-border);
    color: var(--ice);
    box-shadow: 0 2px 8px rgba(28, 126, 214, 0.15);
}

/* Thunder checked */
.radio-card input[type="radio"]:checked ~ .radio-visual.thunder {
    background: var(--thunder-bg);
    border-color: var(--thunder-border);
    color: var(--thunder);
    box-shadow: 0 2px 8px rgba(245, 159, 0, 0.15);
}

/* ── Weapon Grid ── */
.weapon-grid-section {
    margin-bottom: 24px;
}

.weapon-grid,
.horse-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.weapon-grid .grid-btn,
.horse-grid .grid-btn {
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.grid-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.grid-btn:active {
    transform: translateY(0) scale(0.98);
}

.grid-btn .material-symbols-outlined {
    font-size: 16px;
}

/* Grid button type colors on hover */
.grid-btn[data-type="standard"]:hover {
    background: rgba(13, 110, 253, 0.06);
    border-color: rgba(13, 110, 253, 0.25);
    color: #0D6EFD;
}

.grid-btn[data-type="power"]:hover {
    background: rgba(220, 53, 69, 0.06);
    border-color: rgba(220, 53, 69, 0.25);
    color: #DC3545;
}

.grid-btn[data-type="skill"]:hover {
    background: rgba(111, 66, 193, 0.06);
    border-color: rgba(111, 66, 193, 0.25);
    color: #6F42C1;
}

.grid-btn[data-horse="red"]:hover {
    background: rgba(220, 53, 69, 0.06);
    border-color: rgba(220, 53, 69, 0.25);
    color: #DC3545;
}

.grid-btn[data-horse="shadow"]:hover {
    background: rgba(111, 66, 193, 0.06);
    border-color: rgba(111, 66, 193, 0.25);
    color: #6F42C1;
}

.grid-btn[data-horse="dew"]:hover {
    background: rgba(25, 135, 84, 0.06);
    border-color: rgba(25, 135, 84, 0.25);
    color: #198754;
}

/* ── Action Buttons Row ── */
.action-buttons-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.action-buttons-row .btn {
    flex: 1;
}

/* ── Info Banner ── */
.info-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-banner .material-symbols-outlined {
    font-size: 20px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 1px;
}

.info-banner strong {
    color: var(--text);
}

.horse-info-banners {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

.info-banner.info-red {
    background: rgba(220, 53, 69, 0.06);
    border-color: rgba(220, 53, 69, 0.2);
}

.info-banner.info-red .material-symbols-outlined {
    color: var(--danger);
}

.info-banner.info-purple {
    background: rgba(111, 66, 193, 0.06);
    border-color: rgba(111, 66, 193, 0.2);
}

.info-banner.info-purple .material-symbols-outlined {
    color: var(--accent);
}

.info-banner.info-green {
    background: rgba(25, 135, 84, 0.06);
    border-color: rgba(25, 135, 84, 0.2);
}

.info-banner.info-green .material-symbols-outlined {
    color: var(--success);
}

/* ── Toast Notifications ── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--text);
    pointer-events: auto;
    animation: toastIn 0.35s ease;
    max-width: 380px;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.toast .material-symbols-outlined {
    font-size: 22px;
    flex-shrink: 0;
}

.toast.success .material-symbols-outlined {
    color: var(--success);
}

.toast.error .material-symbols-outlined {
    color: var(--danger);
}

.toast.warning .material-symbols-outlined {
    color: var(--fire);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalOverlayIn 0.25s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 90%;
    animation: modalBoxIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.modal-icon {
    font-size: 28px;
    color: var(--fire);
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-box p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 22px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ── Utility ── */
.hidden {
    display: none !important;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    html {
        font-size: 14px;
    }

    .header-inner {
        padding: 12px 16px;
    }

    #app-main {
        padding: 14px 12px 32px;
    }

    #tab-nav {
        gap: 2px;
        padding: 4px;
    }

    .tab-btn {
        padding: 10px 8px;
        font-size: 0.82rem;
        gap: 4px;
        flex-direction: column;
    }

    .tab-btn .material-symbols-outlined {
        font-size: 18px;
    }

    .panel-card {
        padding: 18px 14px;
    }

    .warrior-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .warrior-controls .btn {
        width: 100%;
    }

    .select-input {
        width: 100%;
        min-width: unset;
    }

    .weapon-grid,
    .horse-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .grid-btn {
        font-size: 0.75rem !important;
        padding: 8px 4px !important;
    }

    .radio-group {
        gap: 6px;
    }

    .radio-visual {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .action-buttons-row {
        flex-direction: column;
    }

    .file-input-row {
        flex-direction: column;
    }

    .file-name-display {
        width: 100%;
    }

    .btn-primary#btn-file-select {
        width: 100%;
    }

    #toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    .toast {
        max-width: 100%;
    }
}
