/* ============================================================
   Bcrypt Toolkit — app.css
   ============================================================ */

/* CSS Variables */
:root {
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-surface-alt: #f0f4ff;
    --color-border: #d1d9e6;
    --color-text: #1a1f2e;
    --color-text-muted: #5a6478;
    --color-primary: #3b5bdb;
    --color-primary-hover: #2f4ac4;
    --color-primary-text: #ffffff;
    --color-secondary: #e9ecef;
    --color-secondary-hover: #dee2e6;
    --color-secondary-text: #1a1f2e;
    --color-success-bg: #d3f9d8;
    --color-success-border: #40c057;
    --color-success-text: #1a5c2a;
    --color-error-bg: #ffe3e3;
    --color-error-border: #fa5252;
    --color-error-text: #7d1a1a;
    --color-notice-bg: #e7f5ff;
    --color-notice-border: #339af0;
    --color-notice-text: #1864ab;
    --color-header-bg: #1e2a4a;
    --color-header-text: #ffffff;
    --color-footer-bg: #1e2a4a;
    --color-footer-text: #a8b4cc;
    --color-brand-icon: #74c0fc;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-focus: 0 0 0 3px rgba(59, 91, 219, 0.3);
    --transition: 0.2s ease;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
    --max-width: 1000px;
}

[data-theme="dark"] {
    --color-bg: #0f1117;
    --color-surface: #1a1f2e;
    --color-surface-alt: #1e2540;
    --color-border: #2e3650;
    --color-text: #e8ecf4;
    --color-text-muted: #8a96b0;
    --color-primary: #5c7cfa;
    --color-primary-hover: #4c6ef5;
    --color-primary-text: #ffffff;
    --color-secondary: #2e3650;
    --color-secondary-hover: #3a4468;
    --color-secondary-text: #e8ecf4;
    --color-success-bg: #0d2e14;
    --color-success-border: #40c057;
    --color-success-text: #69db7c;
    --color-error-bg: #2e0d0d;
    --color-error-border: #fa5252;
    --color-error-text: #ff8787;
    --color-notice-bg: #0d1e2e;
    --color-notice-border: #339af0;
    --color-notice-text: #74c0fc;
    --color-header-bg: #0d1117;
    --color-header-text: #e8ecf4;
    --color-footer-bg: #0d1117;
    --color-footer-text: #5a6478;
    --color-brand-icon: #5c7cfa;
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-focus: 0 0 0 3px rgba(92, 124, 250, 0.35);
}

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

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition), color var(--transition);
}

/* Container */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
    background-color: var(--color-header-bg);
    color: var(--color-header-text);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 36px;
    height: 36px;
    fill: var(--color-brand-icon);
    flex-shrink: 0;
}

.site-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-header-text);
    letter-spacing: -0.02em;
}

.site-subtitle {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.1rem;
}

/* ============================================================
   Theme Toggle Button
   ============================================================ */
.btn-icon {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    color: inherit;
    transition: background-color var(--transition), border-color var(--transition);
}

.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-icon:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

#themeToggle {
    color: var(--color-header-text);
    width: 38px;
    height: 38px;
}

#themeToggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* ============================================================
   Privacy Notice
   ============================================================ */
.privacy-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background-color: var(--color-notice-bg);
    border: 1px solid var(--color-notice-border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1.125rem;
    color: var(--color-notice-text);
    font-size: 0.875rem;
}

.notice-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    margin-top: 0.1rem;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-border);
}

/* ============================================================
   Form Elements
   ============================================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.label-hint {
    font-weight: 400;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.textarea-wrapper {
    align-items: flex-start;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.form-input.has-actions {
    padding-right: 5.5rem;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.output-textarea {
    background-color: var(--color-surface-alt);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    min-height: 70px;
    resize: none;
    cursor: text;
}

/* Input action buttons */
.input-action {
    position: absolute;
    right: 0.5rem;
    color: var(--color-text-muted);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
}

.input-action:hover {
    color: var(--color-text);
    background-color: var(--color-secondary);
}

.input-action svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Two action buttons */
.input-wrapper:has(#toggleGenerateText) .form-input,
.input-wrapper:has(#toggleVerifyText) .form-input {
    padding-right: 5.5rem;
}

#toggleGenerateText { right: 2.5rem; }
#clearGenerateText { right: 0.4rem; }
#toggleVerifyText { right: 0.4rem; }

.textarea-clear {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
}

.input-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-align: right;
}

.field-error {
    font-size: 0.8rem;
    color: var(--color-error-text);
    min-height: 1.2em;
}

/* ============================================================
   Cost Factor Controls
   ============================================================ */
.cost-factor-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cost-btn {
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    background-color: var(--color-surface);
    flex-shrink: 0;
}

.cost-btn:hover {
    background-color: var(--color-secondary);
    border-color: var(--color-primary);
}

.cost-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.cost-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    min-width: 2rem;
    text-align: center;
}

.cost-slider {
    flex: 1;
    min-width: 120px;
    accent-color: var(--color-primary);
    cursor: pointer;
    height: 4px;
}

.cost-note {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.375rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition), opacity var(--transition), transform var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-primary-text);
    align-self: flex-start;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--color-secondary-hover);
}

/* Spinner */
.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-text { opacity: 0.8; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Result Box
   ============================================================ */
.result-box {
    background-color: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.125rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.output-wrapper {
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
}

.output-wrapper .form-textarea {
    flex: 1;
}

.copy-btn {
    flex-shrink: 0;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
}

.copy-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.copy-message {
    font-size: 0.8rem;
    color: var(--color-success-text);
    font-weight: 500;
}

.hash-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.meta-item strong {
    color: var(--color-text);
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background-color: var(--color-success-bg);
    border-color: var(--color-success-border);
    color: var(--color-success-text);
}

.alert-error {
    background-color: var(--color-error-bg);
    border-color: var(--color-error-border);
    color: var(--color-error-text);
}

.verify-time {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* ============================================================
   Information / Accordion
   ============================================================ */
.info-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
}

.accordion {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.accordion-item {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.accordion-summary {
    padding: 0.875rem 1.125rem;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text);
    transition: background-color var(--transition);
    user-select: none;
}

.accordion-summary::-webkit-details-marker { display: none; }

.accordion-summary::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--color-primary);
    transition: transform var(--transition);
    flex-shrink: 0;
}

details[open] .accordion-summary::after {
    content: '−';
}

.accordion-summary:hover {
    background-color: var(--color-surface-alt);
}

.accordion-summary:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.accordion-content {
    padding: 0 1.125rem 1rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.7;
}

.accordion-content p + p { margin-top: 0.5rem; }

.accordion-content ul {
    margin-top: 0.5rem;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
    background-color: var(--color-footer-bg);
    color: var(--color-footer-text);
    padding: 2rem 0;
    margin-top: auto;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
}

.footer-brand {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
}

.footer-tagline {
    font-size: 0.8rem;
}

.footer-copy {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0.6;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
    .card {
        padding: 1.25rem;
    }

    .cost-factor-controls {
        gap: 0.5rem;
    }

    .cost-slider {
        min-width: 80px;
    }

    .output-wrapper {
        flex-direction: column;
    }

    .copy-btn {
        align-self: flex-start;
    }

    .hash-meta {
        gap: 0.4rem 1rem;
    }

    .btn-primary {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .site-title { font-size: 1.1rem; }
    .site-subtitle { display: none; }
}
