/* ============================================================
   HTML Formatter Tool — style.css
   Plugin Version: 1.0.0
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;600;700;800&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */
:root {
    /* Light theme */
    --hft-bg:           #f4f1ed;
    --hft-surface:      #ffffff;
    --hft-surface-2:    #faf8f5;
    --hft-border:       #e2ddd6;
    --hft-border-focus: #1a1a2e;

    --hft-text-primary:   #1a1a2e;
    --hft-text-secondary: #6b6570;
    --hft-text-muted:     #9e97a3;

    --hft-accent:         #e84545;
    --hft-accent-hover:   #c93a3a;
    --hft-accent-soft:    #fdeaea;

    --hft-success:        #2a9d5c;
    --hft-success-soft:   #e7f7ef;

    --hft-code-bg:        #f8f6f2;
    --hft-line-no-color:  #c5bfcb;

    --hft-font-ui:        'Syne', sans-serif;
    --hft-font-code:      'Space Mono', monospace;

    --hft-radius:         12px;
    --hft-radius-sm:      8px;
    --hft-shadow:         0 2px 12px rgba(26,26,46,0.08);
    --hft-shadow-lg:      0 8px 32px rgba(26,26,46,0.12);

    --hft-transition:     0.2s ease;
}

/* ── Dark Theme ───────────────────────────────────────────── */
.hft-dark {
    --hft-bg:           #0f0f1a;
    --hft-surface:      #1a1a2e;
    --hft-surface-2:    #14141f;
    --hft-border:       #2d2d45;
    --hft-border-focus: #e84545;

    --hft-text-primary:   #f0edf7;
    --hft-text-secondary: #9e97c8;
    --hft-text-muted:     #5a5575;

    --hft-accent:         #e84545;
    --hft-accent-hover:   #ff5f5f;
    --hft-accent-soft:    #2d1a1a;

    --hft-success:        #3ecf7e;
    --hft-success-soft:   #0e2a1c;

    --hft-code-bg:        #12121e;
    --hft-line-no-color:  #3a3552;

    --hft-shadow:         0 2px 12px rgba(0,0,0,0.4);
    --hft-shadow-lg:      0 8px 32px rgba(0,0,0,0.6);
}

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

/* ── Wrapper ──────────────────────────────────────────────── */
.hft-wrapper {
    background: var(--hft-bg);
    border-radius: var(--hft-radius);
    padding: 32px 28px 28px;
    font-family: var(--hft-font-ui);
    color: var(--hft-text-primary);
    transition: background var(--hft-transition), color var(--hft-transition);
    border: 1px solid var(--hft-border);
    box-shadow: var(--hft-shadow-lg);
    max-width: 1280px;
    margin: 0 auto;
}

/* ── Header ───────────────────────────────────────────────── */
.hft-header {
    margin-bottom: 24px;
}

.hft-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.hft-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hft-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--hft-accent);
    color: #fff;
    font-family: var(--hft-font-code);
    font-weight: 700;
    font-size: 14px;
    border-radius: var(--hft-radius-sm);
    flex-shrink: 0;
    letter-spacing: -1px;
    box-shadow: 3px 3px 0 rgba(232,69,69,0.3);
}

.hft-title {
    font-size: clamp(20px, 2.5vw, 28px);
    font-weight: 800;
    color: var(--hft-text-primary);
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.hft-subtitle {
    margin-top: 8px;
    font-size: 14px;
    color: var(--hft-text-secondary);
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* ── Dark Mode Toggle ─────────────────────────────────────── */
.hft-dark-toggle {
    background: var(--hft-surface);
    border: 1px solid var(--hft-border);
    border-radius: 50px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 16px;
    transition: all var(--hft-transition);
    color: var(--hft-text-primary);
    flex-shrink: 0;
}

.hft-dark-toggle:hover {
    border-color: var(--hft-accent);
    box-shadow: 0 0 0 3px var(--hft-accent-soft);
    transform: scale(1.05);
}

/* ── Toolbar ──────────────────────────────────────────────── */
.hft-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: var(--hft-surface);
    border: 1px solid var(--hft-border);
    border-radius: var(--hft-radius);
    box-shadow: var(--hft-shadow);
}

.hft-toolbar-left,
.hft-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Buttons ──────────────────────────────────────────────── */
.hft-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--hft-radius-sm);
    font-family: var(--hft-font-ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--hft-transition);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.hft-btn-icon {
    font-size: 12px;
    opacity: 0.85;
}

.hft-btn-primary {
    background: var(--hft-accent);
    color: #fff;
    box-shadow: 3px 3px 0 var(--hft-accent-hover);
}

.hft-btn-primary:hover {
    background: var(--hft-accent-hover);
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--hft-accent-hover);
}

.hft-btn-primary:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--hft-accent-hover);
}

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

.hft-btn-secondary:hover {
    border-color: var(--hft-accent);
    color: var(--hft-accent);
    background: var(--hft-accent-soft);
}

/* ── Select + Options ─────────────────────────────────────── */
.hft-option-label {
    font-size: 13px;
    color: var(--hft-text-secondary);
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.hft-select {
    padding: 8px 12px;
    border: 1px solid var(--hft-border);
    border-radius: var(--hft-radius-sm);
    background: var(--hft-surface);
    color: var(--hft-text-primary);
    font-family: var(--hft-font-ui);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--hft-transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b6570' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.hft-select:hover,
.hft-select:focus {
    border-color: var(--hft-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--hft-accent-soft);
}

.hft-lines-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.hft-checkbox {
    accent-color: var(--hft-accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* ── Editors Layout ───────────────────────────────────────── */
.hft-editors {
    display: grid;
    grid-template-columns: 1fr 40px 1fr;
    gap: 0;
    align-items: stretch;
    min-height: 420px;
}

/* ── Pane ─────────────────────────────────────────────────── */
.hft-pane {
    display: flex;
    flex-direction: column;
    background: var(--hft-surface);
    border: 1px solid var(--hft-border);
    border-radius: var(--hft-radius);
    overflow: hidden;
    box-shadow: var(--hft-shadow);
    transition: box-shadow var(--hft-transition);
}

.hft-pane:focus-within {
    border-color: var(--hft-border-focus);
    box-shadow: var(--hft-shadow-lg);
}

.hft-pane-input  { border-radius: var(--hft-radius) 0 0 var(--hft-radius); }
.hft-pane-output { border-radius: 0 var(--hft-radius) var(--hft-radius) 0; border-left: none; }

.hft-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--hft-border);
    background: var(--hft-surface-2);
    min-height: 44px;
}

.hft-pane-label {
    font-family: var(--hft-font-code);
    font-size: 11px;
    font-weight: 700;
    color: var(--hft-text-muted);
    letter-spacing: 0.12em;
}

.hft-char-count {
    font-family: var(--hft-font-code);
    font-size: 11px;
    color: var(--hft-text-muted);
}

.hft-output-actions {
    display: flex;
    gap: 4px;
}

/* ── Icon Buttons (copy, download) ───────────────────────── */
.hft-icon-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 15px;
    cursor: pointer;
    color: var(--hft-text-muted);
    transition: all var(--hft-transition);
    line-height: 1;
}

.hft-icon-btn:hover {
    border-color: var(--hft-border);
    background: var(--hft-bg);
    color: var(--hft-text-primary);
    transform: scale(1.1);
}

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

/* ── Textareas ────────────────────────────────────────────── */
.hft-textarea {
    flex: 1;
    width: 100%;
    padding: 16px;
    background: var(--hft-code-bg);
    color: var(--hft-text-primary);
    font-family: var(--hft-font-code);
    font-size: 13px;
    line-height: 1.7;
    border: none;
    resize: none;
    outline: none;
    transition: background var(--hft-transition);
    tab-size: 4;
    min-height: 376px;
}

.hft-textarea::placeholder {
    color: var(--hft-text-muted);
    font-style: italic;
}

.hft-textarea-output {
    cursor: default;
}

/* ── Output wrap (for line numbers overlay) ─────────────── */
.hft-output-wrap {
    flex: 1;
    position: relative;
    display: flex;
}

.hft-output-wrap .hft-textarea {
    flex: 1;
    padding-left: 16px;
    transition: padding-left var(--hft-transition);
}

.hft-output-wrap.show-lines .hft-textarea {
    padding-left: 52px;
}

.hft-line-numbers {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 44px;
    padding: 16px 8px 16px 0;
    background: var(--hft-surface-2);
    border-right: 1px solid var(--hft-border);
    font-family: var(--hft-font-code);
    font-size: 13px;
    line-height: 1.7;
    color: var(--hft-line-no-color);
    text-align: right;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
    white-space: pre;
}

.hft-output-wrap.show-lines .hft-line-numbers {
    display: block;
}

/* ── Divider ──────────────────────────────────────────────── */
.hft-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hft-bg);
    border-top: 1px solid var(--hft-border);
    border-bottom: 1px solid var(--hft-border);
}

.hft-swap-btn {
    background: var(--hft-surface);
    border: 1px solid var(--hft-border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: var(--hft-text-secondary);
    transition: all var(--hft-transition);
    padding: 0;
}

.hft-swap-btn:hover {
    background: var(--hft-accent);
    color: #fff;
    border-color: var(--hft-accent);
    transform: scale(1.1);
}

/* ── Status bar ───────────────────────────────────────────── */
.hft-status {
    margin-top: 14px;
    min-height: 28px;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--hft-radius-sm);
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(4px);
}

.hft-status.hft-status-success {
    opacity: 1;
    transform: translateY(0);
    background: var(--hft-success-soft);
    color: var(--hft-success);
    border: 1px solid var(--hft-success);
}

.hft-status.hft-status-error {
    opacity: 1;
    transform: translateY(0);
    background: var(--hft-accent-soft);
    color: var(--hft-accent);
    border: 1px solid var(--hft-accent);
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes hft-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(232,69,69,0.4); }
    70%  { box-shadow: 0 0 0 8px rgba(232,69,69,0); }
    100% { box-shadow: 0 0 0 0 rgba(232,69,69,0); }
}

.hft-btn-primary.hft-btn-active {
    animation: hft-pulse 0.4s ease;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .hft-wrapper {
        padding: 20px 16px;
        border-radius: var(--hft-radius-sm);
    }

    .hft-editors {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        min-height: auto;
    }

    .hft-pane-input  {
        border-radius: var(--hft-radius) var(--hft-radius) 0 0;
    }
    .hft-pane-output {
        border-radius: 0 0 var(--hft-radius) var(--hft-radius);
        border-left: 1px solid var(--hft-border);
        border-top: none;
    }

    .hft-divider {
        border-left: 1px solid var(--hft-border);
        border-right: 1px solid var(--hft-border);
        height: 36px;
    }

    .hft-textarea {
        min-height: 240px;
    }

    .hft-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .hft-title {
        font-size: 18px;
    }

    .hft-btn {
        padding: 9px 14px;
        font-size: 13px;
    }
}
