/* ========================================================================
   Git Diff ↔ Patch — Styles
   ======================================================================== */

:root {
    --font: 'Inter', system-ui, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    --bg: #0F0A1A;
    --bg-secondary: #1A1230;
    --bg-card: rgba(26, 18, 48, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(249, 115, 22, 0.5);
    --text: #F0F0F5;
    --text-secondary: #8B8FA3;
    --text-muted: #5A5E72;
    --accent: #F97316;
    --accent2: #EF4444;
    --gradient: linear-gradient(135deg, #F97316, #EF4444);
    --add-bg: rgba(16, 185, 129, 0.1);
    --add-color: #10B981;
    --del-bg: rgba(239, 68, 68, 0.1);
    --del-color: #EF4444;
    --hunk-bg: rgba(59, 130, 246, 0.1);
    --hunk-color: #3B82F6;
    --meta-color: #A78BFA;
    --conflict-bg: rgba(249, 115, 22, 0.15);
    --conflict-color: #F97316;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #F5F6FA;
    --bg-secondary: #FFF;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-glass-hover: rgba(0, 0, 0, 0.04);
    --bg-input: rgba(0, 0, 0, 0.04);
    --border: rgba(0, 0, 0, 0.08);
    --text: #1A1D2E;
    --text-secondary: #5A5E72;
    --text-muted: #8B8FA3;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.08);
    --add-bg: rgba(16, 185, 129, 0.08);
    --del-bg: rgba(239, 68, 68, 0.08);
    --hunk-bg: rgba(59, 130, 246, 0.08);
    --conflict-bg: rgba(249, 115, 22, 0.1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: -40%;
    left: -20%;
    width: 70%;
    height: 70%;
    background: radial-gradient(ellipse, rgba(249, 115, 22, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-title {
    font-size: 1.125rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 0.375rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    transition: all var(--transition);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
    padding: 0.625rem 1.5rem;
    font-size: 0.875rem;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(249, 115, 22, 0.4);
}

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

.btn-ghost:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
    border-color: var(--border);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-icon {
    padding: 0.5rem;
}

.main {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    padding: 0.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    width: fit-content;
    margin-inline: auto;
}

.mode-btn {
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.mode-btn.active {
    background: var(--gradient);
    color: #fff;
}

.mode-btn:hover:not(.active) {
    color: var(--text);
    background: var(--bg-glass-hover);
}

/* Panels */
.panels {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    align-items: stretch;
}

.panel {
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-glass);
}

.panel-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: var(--mono);
}

.panel-actions {
    display: flex;
    gap: 0.25rem;
}

.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-glass);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.code-area {
    flex: 1;
    width: 100%;
    padding: 1rem;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.7;
    resize: none;
    min-height: 350px;
    tab-size: 2;
    outline: none;
}

.code-area::placeholder {
    color: var(--text-muted);
}

.code-output {
    overflow: auto;
    white-space: pre;
    min-height: 350px;
}

.convert-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
}

.btn-convert {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 0;
}

/* Syntax highlighting lines */
.line-add {
    background: var(--add-bg);
    color: var(--add-color);
    display: block;
}

.line-del {
    background: var(--del-bg);
    color: var(--del-color);
    display: block;
}

.line-hunk {
    background: var(--hunk-bg);
    color: var(--hunk-color);
    display: block;
    font-weight: 600;
}

.line-meta {
    color: var(--meta-color);
    display: block;
    font-weight: 600;
}

.line-ctx {
    color: var(--text-secondary);
    display: block;
}

.line-conflict {
    background: var(--conflict-bg);
    color: var(--conflict-color);
    display: block;
    font-weight: 600;
}

/* Info Cards */
.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.info-card {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    animation: fadeInUp 0.4s ease-out backwards;
}

.info-card:nth-child(1) {
    animation-delay: 0s;
}

.info-card:nth-child(2) {
    animation-delay: 0.06s;
}

.info-card:nth-child(3) {
    animation-delay: 0.12s;
}

.info-card:nth-child(4) {
    animation-delay: 0.18s;
}

.info-card:nth-child(5) {
    animation-delay: 0.24s;
}

.info-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value.add {
    color: var(--add-color);
}

.info-value.del {
    color: var(--del-color);
}

.info-value.files {
    color: var(--hunk-color);
}

.info-value.hunks {
    color: var(--meta-color);
}

.info-value.conflict {
    color: var(--conflict-color);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    animation: scaleIn 0.25s ease-out;
}

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

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.modal-footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.history-item {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.history-item:hover {
    background: var(--bg-glass-hover);
}

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

.history-formula {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.empty-history {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .panels {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .convert-divider {
        padding: 0.5rem 0;
    }

    .btn-convert {
        transform: rotate(90deg);
    }

    .header-content {
        padding: 0.625rem 1rem;
    }

    .main {
        padding: 1rem;
    }

    .logo-subtitle {
        display: none;
    }

    .code-area {
        min-height: 200px;
    }
}