/* ============================================================
   BehixoConvert - Unit Conversion Website
   Color Theme: Orange / Amber
   ============================================================ */

/* ------------------------------------------------------------
   1. CSS Custom Properties
   ------------------------------------------------------------ */
:root {
    --color-primary: #E67E22;
    --color-primary-hover: #D35400;
    --color-primary-light: #FDF2E9;
    --color-background: #FAFAFA;
    --color-surface: #FFFFFF;
    --color-text-primary: #2C3E50;
    --color-text-secondary: #7F8C8D;
    --color-border: #E8E8E8;
    --color-error: #E74C3C;
    --color-success: #27AE60;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 10px;
    --radius-lg: 14px;
    --container-max: 1140px;
    --font-stack: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--color-background);
    font-family: var(--font-stack);
    color: var(--color-text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style: none;
}

button {
    font-family: inherit;
}

/* ------------------------------------------------------------
   3. Container
   ------------------------------------------------------------ */
.container {
    max-width: var(--container-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
    width: 100%;
}

/* ------------------------------------------------------------
   4. Header (.site-header)
   ------------------------------------------------------------ */
.site-header {
    background-color: var(--color-surface);
    border-bottom: 1px solid rgba(230, 126, 34, 0.12);
    padding: 16px 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-header__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.site-header__logo svg {
    width: 32px;
    height: 32px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.site-header__logo span {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-primary);
    letter-spacing: -0.01em;
}

.site-header__tagline {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

/* ------------------------------------------------------------
   5. Footer (.site-footer)
   ------------------------------------------------------------ */
.site-footer {
    margin-top: 30px;
    border-top: 1px solid var(--color-border);
    padding: 24px 0;
    text-align: center;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--color-text-secondary);
    font-size: 0.88rem;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--color-primary);
}

.footer-links .separator {
    color: var(--color-border);
    user-select: none;
}

.site-footer__copy {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

/* ------------------------------------------------------------
   6. Hero Section (.hero)
   ------------------------------------------------------------ */
.hero {
    text-align: center;
    padding: 48px 0 40px;
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--color-text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.hero p {
    color: var(--color-text-secondary);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    font-size: 1.05rem;
    line-height: 1.6;
}

/* ------------------------------------------------------------
   7. Category Sections (.category-section)
   ------------------------------------------------------------ */
.category-section {
    margin-bottom: 48px;
}

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

.category-header svg {
    width: 28px;
    height: 28px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.category-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.01em;
}

.section__heading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.01em;
    padding: 15px 0;
}

.section__heading-icon svg {
    width: 28px;
    height: 28px;
    color: var(--color-primary);
    flex-shrink: 0;
}

/* ------------------------------------------------------------
   8. Tool Cards Grid (.tools-grid)
   ------------------------------------------------------------ */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ------------------------------------------------------------
   9. Tool Cards (.tool-card)
   ------------------------------------------------------------ */
.tool-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.tool-card--popular {
    padding: 24px;
}

.tool-card--niche {
    padding: 16px;
}

.tool-card--niche .tool-card__title {
    font-size: 0.92rem;
}

.tool-card--niche .tool-card__tagline {
    font-size: 0.8rem;
}

/* ------------------------------------------------------------
   10. Tool Card Inner Elements
   ------------------------------------------------------------ */
.tool-card__icon {
    margin-bottom: 12px;
}

.tool-card__icon svg {
    width: 32px;
    height: 32px;
    color: var(--color-primary);
}

.tool-card__title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--color-text-primary);
    line-height: 1.3;
}

.tool-card__tagline {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.tool-card__fav {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.3;
    padding: 4px;
    transition: opacity 0.2s, color 0.2s;
    color: var(--color-text-secondary);
}

.tool-card__fav:hover,
.tool-card__fav.active {
    opacity: 1;
    color: #F39C12;
}

.tool-card__fav .star-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    width: 18px;
    height: 18px;
}

.tool-card__fav.active .star-icon {
    fill: currentColor;
}

/* ------------------------------------------------------------
   11. Favorites Section (#favorites)
   ------------------------------------------------------------ */
#favorites {
    background-color: var(--color-primary-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 36px;
}

#favorites h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--color-text-primary);
}

#favorites .tools-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* ------------------------------------------------------------
   12. Tool Page Styles
   ------------------------------------------------------------ */
.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--color-primary);
    text-decoration: none;
    margin-top: 24px;
    margin-bottom: 20px;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    text-decoration: underline;
}

.back-link svg {
    width: 16px;
    height: 16px;
}

.tool-header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.tool-header svg {
    width: 40px;
    height: 40px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.tool-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.01em;
}

.tool-header p {
    color: var(--color-text-secondary);
    width: 100%;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ------------------------------------------------------------
   13. Form Styles
   ------------------------------------------------------------ */
.form-card {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--color-text-primary);
}

input[type="number"],
input[type="text"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-stack);
    color: var(--color-text-primary);
    background-color: var(--color-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    line-height: 1.5;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.15);
}

input[type="number"]::placeholder,
input[type="text"]::placeholder,
textarea::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.7;
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-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='%237F8C8D' d='M6 8.825L0.375 3.2l.85-.85L6 7.125 10.775 2.35l.85.85z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    cursor: pointer;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ------------------------------------------------------------
   13b. Unit Row (from / swap / to inline)
   ------------------------------------------------------------ */
.unit-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.unit-row .form-group {
    flex: 1;
    min-width: 0;
}

/* ------------------------------------------------------------
   14. Swap Button (.swap-btn)
   ------------------------------------------------------------ */
.swap-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--color-primary-light);
    border: 1px solid rgba(230, 126, 34, 0.3);
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.swap-btn svg {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
    transition: color 0.3s ease, transform 0.3s ease;
}

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

.swap-btn:hover svg {
    color: var(--color-surface);
    transform: rotate(180deg);
}

.currency-updated {
    text-align: center;
    font-size: 0.88rem;
    color: var(--color-text-secondary);
    margin-bottom: 15px;
}

/* ------------------------------------------------------------
   15. Convert Button (.btn-convert)
   ------------------------------------------------------------ */
.btn-convert {
    width: 100%;
    padding: 14px;
    background-color: var(--color-primary);
    color: var(--color-surface);
    border: none;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    font-family: var(--font-stack);
    cursor: pointer;
    transition: background-color 0.2s ease;
    line-height: 1.4;
}

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

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

.btn-convert.loading {
    position: relative;
    pointer-events: none;
}

/* ------------------------------------------------------------
   16. Result Card (.result-card)
   ------------------------------------------------------------ */
.result-card {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--color-success);
    margin-bottom: 24px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.result-header h3 {
    font-size: 1.1rem;
    color: var(--color-success);
    font-weight: 600;
}

.result-content {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-text-primary);
    word-break: break-all;
    margin-bottom: 12px;
    line-height: 1.3;
}

.result-formula {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
    background-color: #F5F5F5;
    padding: 12px;
    border-radius: 6px;
    line-height: 1.6;
    overflow-x: auto;
}

/* ------------------------------------------------------------
   17. Copy Button (.copy-btn)
   ------------------------------------------------------------ */
.copy-btn {
    padding: 6px 16px;
    background-color: #F5F5F5;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: var(--font-stack);
    cursor: pointer;
    color: var(--color-text-primary);
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
}

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

.copy-btn.copied {
    background-color: var(--color-success);
    border-color: var(--color-success);
    color: var(--color-surface);
}

/* ------------------------------------------------------------
   18. Error Card (.error-card)
   ------------------------------------------------------------ */
.error-card {
    background-color: #FDF0EF;
    border-left: 4px solid var(--color-error);
    border-radius: var(--radius-lg);
    padding: 20px;
    color: var(--color-error);
    font-weight: 500;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ------------------------------------------------------------
   19. Quick Links Section (.quick-links)
   ------------------------------------------------------------ */
.quick-links {
    margin-top: 36px;
}

.quick-links h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.quick-links-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-link {
    padding: 6px 14px;
    background-color: var(--color-primary-light);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--color-primary);
    text-decoration: none;
    border: 1px solid transparent;
    font-weight: 500;
    transition: border-color 0.2s, background-color 0.2s;
    white-space: nowrap;
}

.quick-link:hover {
    border-color: var(--color-primary);
    background-color: var(--color-surface);
}

/* ------------------------------------------------------------
   20. SEO Content (.seo-content)
   ------------------------------------------------------------ */
.seo-content {
    margin-top: 36px;
    padding-top: 36px;
    border-top: 1px solid var(--color-border);
}

.seo-content h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--color-text-primary);
}

.seo-content p {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.seo-content ul,
.seo-content ol {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
    padding-left: 20px;
    list-style: disc;
}

.seo-content ol {
    list-style: decimal;
}

/* ------------------------------------------------------------
   21. Legal Pages (.legal-content)
   ------------------------------------------------------------ */
.legal-content {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding: 40px 0;
}

.legal-content h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--color-text-primary);
}

.legal-content .legal-date {
    color: var(--color-text-secondary);
    margin-bottom: 32px;
    font-size: 0.9rem;
}

.legal-content h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 28px;
    margin-bottom: 12px;
    color: var(--color-text-primary);
}

.legal-content p,
.legal-content ul,
.legal-content ol {
    line-height: 1.7;
    margin-bottom: 16px;
    color: var(--color-text-secondary);
}

.legal-content ul,
.legal-content ol {
    padding-left: 24px;
}

.legal-content ul {
    list-style: disc;
}

.legal-content ol {
    list-style: decimal;
}

.legal-content a {
    color: var(--color-primary);
    text-decoration: underline;
}

.legal-content a:hover {
    color: var(--color-primary-hover);
}

/* ------------------------------------------------------------
   22. 404 Page (.not-found)
   ------------------------------------------------------------ */
.not-found {
    text-align: center;
    padding: 80px 0;
}

.not-found h1 {
    font-size: 5rem;
    color: var(--color-primary);
    margin-bottom: 0;
    line-height: 1;
    font-weight: 800;
}

.not-found h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--color-text-primary);
    font-weight: 700;
}

.not-found p {
    color: var(--color-text-secondary);
    margin-bottom: 24px;
    font-size: 1.05rem;
}

.btn-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background-color: var(--color-primary);
    color: var(--color-surface);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-home:hover {
    background-color: var(--color-primary-hover);
    box-shadow: var(--shadow-md);
}

/* ------------------------------------------------------------
   23. Loading Spinner
   ------------------------------------------------------------ */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-surface);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

/* ------------------------------------------------------------
   24. Utility Classes
   ------------------------------------------------------------ */
.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

/* ------------------------------------------------------------
   25. Responsive Design
   ------------------------------------------------------------ */

/* Large desktop: 4 columns (default, above 900px) */

/* Tablet: 3 columns */
@media (max-width: 900px) {
    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    #favorites .tools-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .hero h1 {
        font-size: 1.9rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .form-card {
        padding: 24px;
    }

    .category-header h2 {
        font-size: 1.25rem;
    }

    .result-content {
        font-size: 1.5rem;
    }
}

/* Small tablet / large mobile: 2 columns */
@media (max-width: 640px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #favorites .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .site-header .container {
        flex-wrap: wrap;
        gap: 4px;
    }

    .site-header__tagline {
        display: none;
    }

    .hero {
        padding: 32px 0 28px;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .tool-header {
        gap: 12px;
    }

    .tool-header h1 {
        font-size: 1.35rem;
    }

    .tool-header svg {
        width: 32px;
        height: 32px;
    }

    .unit-row {
        flex-direction: column;
        align-items: stretch;
    }

    .unit-row .swap-btn {
        margin: 0 auto;
    }

    .form-card {
        padding: 20px;
    }

    .form-group label {
        font-size: 0.85rem;
    }

    input[type="number"],
    input[type="text"],
    select,
    textarea {
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    .btn-convert {
        padding: 12px;
        font-size: 1rem;
    }

    .result-content {
        font-size: 1.4rem;
    }

    .category-section {
        margin-bottom: 36px;
    }

    .category-header h2 {
        font-size: 1.15rem;
    }

    .category-header svg {
        width: 24px;
        height: 24px;
    }

    .not-found {
        padding: 48px 0;
    }

    .not-found h1 {
        font-size: 3.5rem;
    }

    .not-found h2 {
        font-size: 1.25rem;
    }

    .legal-content {
        padding: 24px 0;
    }

    .legal-content h1 {
        font-size: 1.5rem;
    }

    .footer-links {
        gap: 10px;
    }
}

/* Mobile: 1 column */
@media (max-width: 400px) {
    .tools-grid {
        grid-template-columns: 1fr;
    }

    #favorites .tools-grid {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 1.4rem;
    }

    .hero {
        padding: 24px 0 20px;
    }

    .form-card {
        padding: 16px;
        border-radius: var(--radius);
    }

    .result-card {
        padding: 16px;
    }

    .result-content {
        font-size: 1.2rem;
    }

    .tool-card {
        padding: 16px;
    }

    .tool-card--popular {
        padding: 18px;
    }

    #favorites {
        padding: 16px;
        border-radius: var(--radius);
    }

    .quick-link {
        font-size: 0.75rem;
        padding: 5px 12px;
    }

    .back-link {
        font-size: 0.85rem;
    }

    .site-header__logo span {
        font-size: 1.1rem;
    }

    .site-header__logo svg {
        width: 28px;
        height: 28px;
    }

    .not-found h1 {
        font-size: 3rem;
    }
}

/* ------------------------------------------------------------
   26. Print Styles
   ------------------------------------------------------------ */
@media print {
    body {
        background: white;
    }

    .site-header,
    .site-footer,
    .back-link,
    .swap-btn,
    .btn-convert,
    .copy-btn,
    .tool-card__fav,
    #favorites {
        display: none;
    }

    .tool-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .form-card,
    .result-card {
        box-shadow: none;
    }
}
