/* ============================================
   TOOLZKIT - NEUMORPHIC DESIGN SYSTEM
   ============================================ */

/* CSS Variables - Dark Theme (Default) */
:root,
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #25253a;
    --bg-header: rgba(26, 26, 46, 0.9);
    --text-primary: #f0f0f5;
    --text-muted: #8888a0;
    --accent-primary: #22d3ee;
    --accent-secondary: #a855f7;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --status-active: #22c55e;
    --status-inactive: #6b7280;

    /* Neumorphic Shadows - Dark */
    --shadow-card: 8px 8px 20px rgba(0, 0, 0, 0.5), -4px -4px 16px rgba(255, 255, 255, 0.03);
    --shadow-btn: 6px 6px 14px rgba(0, 0, 0, 0.5), -4px -4px 12px rgba(255, 255, 255, 0.04);
    --shadow-btn-hover: 8px 8px 18px rgba(0, 0, 0, 0.55), -5px -5px 14px rgba(255, 255, 255, 0.05);
    --shadow-in: inset 4px 4px 10px rgba(0, 0, 0, 0.45), inset -3px -3px 8px rgba(255, 255, 255, 0.04);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #e8e8f0;
    --bg-secondary: #f5f5fa;
    --bg-header: rgba(245, 245, 250, 0.95);
    --text-primary: #1a1a2e;
    --text-muted: #666680;
    --accent-primary: #0891b2;
    --accent-secondary: #7c3aed;
    --border-color: rgba(0, 0, 0, 0.08);
    --status-active: #16a34a;
    --status-inactive: #9ca3af;

    /* Neumorphic Shadows - Light */
    --shadow-card: 8px 8px 20px rgba(0, 0, 0, 0.12), -6px -6px 16px rgba(255, 255, 255, 0.9);
    --shadow-btn: 6px 6px 14px rgba(0, 0, 0, 0.12), -4px -4px 12px rgba(255, 255, 255, 0.8);
    --shadow-btn-hover: 8px 8px 18px rgba(0, 0, 0, 0.15), -5px -5px 14px rgba(255, 255, 255, 0.9);
    --shadow-in: inset 4px 4px 10px rgba(0, 0, 0, 0.1), inset -4px -4px 8px rgba(255, 255, 255, 0.7);
}

/* ============================================
   BASE STYLES
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
    overflow: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
    width: 100%;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: var(--bg-header);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 5px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 1px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* ============================================
   SHARED SCROLLBAR STYLES
   ============================================ */
.tk-scrollbar-dark {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-primary) var(--bg-secondary);
    padding-top: 4px;
    padding-bottom: 4px;
}

.tk-scrollbar-dark::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.tk-scrollbar-dark::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.tk-scrollbar-dark::-webkit-scrollbar-thumb {
    background: var(--bg-primary);
    border-radius: 3px;
}

.tk-scrollbar-dark::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Back Button */
.back-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-btn);
    transition: all 0.25s ease;
    text-decoration: none;
}

.back-btn svg {
    stroke: var(--accent-primary);
}

.back-btn:hover {
    box-shadow: var(--shadow-btn-hover);
    transform: translateY(-2px);
}

.back-btn:active {
    box-shadow: var(--shadow-in);
    transform: translateY(0);
}

/* Tool Title */
.tool-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Theme Toggle */
.theme-toggle {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-btn);
    font-size: 1.1rem;
    transition: all 0.25s ease;
}

.theme-toggle:hover {
    box-shadow: var(--shadow-btn-hover);
    transform: translateY(-2px);
}

.theme-toggle:active {
    box-shadow: var(--shadow-in);
    transform: translateY(0);
}

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

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

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

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

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    min-height: 0;
    overflow: hidden;
}

.tool-page .main {
    overflow: hidden;
}

.tool-page .main .container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ============================================
   TOOL PAGES - DESKTOP SCROLLING
   ============================================ */
body.tool-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
}

.tool-page .main {
    overflow: visible;
}

.tool-page .main .container {
    overflow: visible;
}

.tool-page .tool-container {
    overflow: visible;
}

/* ============================================
   HERO SECTION (Homepage)
   ============================================ */
.hero {
    text-align: center;
    padding: 12px 0 16px;
}

.hero-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 6px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ============================================
   CATEGORY CARDS (Homepage)
   ============================================ */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    padding-bottom: 20px;
}

.category-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    padding: 32px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 12px 12px 30px rgba(0, 0, 0, 0.4), -6px -6px 20px rgba(255, 255, 255, 0.05);
}

.category-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.category-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.category-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    min-height: 40px;
}

/* ============================================
   BUTTONS - FULLY NEUMORPHIC
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.25s ease;
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-btn);
}

.btn:hover {
    box-shadow: var(--shadow-btn-hover);
    transform: translateY(-2px);
}

.btn:active {
    box-shadow: var(--shadow-in);
    transform: translateY(0);
}

.btn-primary {
    color: var(--accent-primary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.75rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: var(--shadow-in);
}

/* ============================================
   TOOL PAGE LAYOUT - ADAPTIVE
   ============================================ */
.tool-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tool-layout {
    flex: 1;
    display: flex;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

.tool-layout--split {
    display: flex;
    flex-direction: row;
}

.tool-layout--split>* {
    flex: 1;
    min-width: 0;
}

/* ============================================
   TOOL MENU - NEUMORPHIC
   ============================================ */
tool-menu {
    margin-bottom: 12px;
    flex-shrink: 0;
}

tool-menu a {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-decoration: none;
    color: var(--text-muted);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-btn);
    transition: all 0.25s ease;
}

tool-menu a:hover {
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-btn-hover);
}

tool-menu a.active {
    color: var(--accent-primary);
    box-shadow: var(--shadow-in);
    background: var(--bg-primary);
}

/* ============================================
   INPUT ELEMENTS
   ============================================ */
.input-box {
    padding: 10px 14px;
    border: none;
    border-radius: var(--border-radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow-in);
    transition: all 0.25s ease;
}

.input-box:focus {
    outline: none;
    box-shadow: var(--shadow-in), 0 0 0 2px var(--accent-primary);
}

.input-box-sm {
    width: 80px;
    text-align: center;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.checkbox-input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

.range-slider {
    width: 100px;
    accent-color: var(--accent-primary);
}

select.input-box {
    cursor: pointer;
}

/* Output textarea */
.output-textarea {
    flex: 1;
    width: 100%;
    resize: none;
    background: var(--bg-primary);
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 12px;
    font-size: 0.9rem;
    box-shadow: var(--shadow-in);
}

.output-textarea:focus {
    outline: none;
    box-shadow: var(--shadow-in), 0 0 0 2px var(--accent-primary);
}

/* ============================================
   CONTROLS AREA - NEUMORPHIC
   ============================================ */
.controls-area {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    flex-shrink: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   RESULT STATS
   ============================================ */
.result-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.stat-label {
    color: var(--text-muted);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

.text-success {
    color: #10b981;
}

.text-danger {
    color: #ef4444;
}

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

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar {
    width: 150px;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: var(--shadow-in);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    width: 0%;
    transition: width 0.3s ease;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 10px 24px;
    text-align: center;
    flex-shrink: 0;
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.toast--success {
    background: #10b981;
    color: white;
}

.toast--error {
    background: #ef4444;
    color: white;
}

.toast--info {
    background: #3b82f6;
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* ============================================
   RESPONSIVE - MOBILE SCROLLING FIX
   ============================================ */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .container {
        padding: 0 16px;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .tool-page .main {
        overflow: auto;
    }

    .tool-page .main .container {
        overflow: visible;
    }

    .tool-container {
        overflow: visible;
        min-height: auto;
    }

    .tool-layout {
        overflow: visible;
    }

    .tool-layout--split {
        flex-direction: column;
        min-height: 400px;
    }

    .controls-area {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .header .container {
        padding: 0 12px;
    }

    .tool-title {
        font-size: 1rem;
    }

    .back-btn,
    .theme-toggle {
        width: 38px;
        height: 38px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

.visible {
    display: flex !important;
}

/* ============================================
   HOME PAGE SPECIFIC STYLES
   ============================================ */
.home-page .logo-icon {
    width: 40px;
    height: 40px;
}

.home-page .main {
    overflow-y: auto;
    padding: 24px 0;
}

.home-page .container {
    height: auto;
}

/* Header search button */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-btn);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.25s ease;
    color: #22d3ee;
}

.search-btn:hover {
    transform: scale(1.05);
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box {
    position: absolute;
    right: 52px;
    width: 0;
    overflow: hidden;
    transition: width 0.3s ease;
}

.search-box.active {
    width: 240px;
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    box-shadow: var(--shadow-card);
}

.search-input:focus {
    outline: none;
    box-shadow: var(--shadow-card);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-results {
    position: absolute;
    top: 100%;
    right: 52px;
    width: 240px;
    background: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
    margin-top: 6px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.search-result-item:hover {
    background: var(--bg-primary);
}

.search-result-item .icon {
    font-size: 1rem;
    color: #22d3ee;
}

.search-result-item .name {
    font-weight: 600;
}

.search-result-item .category {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* Section headers - centered with lines */
.section-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.section-line {
    flex: 1;
    max-width: 100px;
    height: 1px;
    background: var(--border-color);
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.section-title tool-icon,
.section-title book-icon {
    color: #22d3ee;
}

/* Cards Grid - squared, same for tools & resources */
.cards-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 36px;
}

.cards-grid .card {
    width: 110px;
    flex-shrink: 0;
}

.card {
    background: var(--bg-secondary);
    border-radius: 14px;
    box-shadow: var(--shadow-card);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.25s ease;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    aspect-ratio: 1;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 10px 10px 24px rgba(0, 0, 0, 0.35), -5px -5px 16px rgba(255, 255, 255, 0.04);
}

.card.disabled {
    opacity: 0.5;
    pointer-events: none;
}

[data-route] {
    display: none;
}

.card-icon {
    font-size: 1.6rem;
    margin-bottom: 8px;
    color: #22d3ee;
}

.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.coming-soon {
    font-size: 0.5rem;
    background: var(--bg-primary);
    color: var(--text-muted);
    padding: 2px 5px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    line-height: 1.2;
}

@media (max-width: 600px) {
    .cards-grid {
        gap: 16px;
    }

    .cards-grid .card {
        width: 100px;
    }

    .card {
        padding: 14px 10px;
    }

    .card-icon {
        font-size: 1.4rem;
        margin-bottom: 6px;
    }

    .card-title {
        font-size: 0.75rem;
    }

    .coming-soon {
        font-size: 0.45rem;
        padding: 2px 4px;
        margin-top: 3px;
    }

    .search-box.active {
        width: 180px;
    }

    .search-results {
        width: 180px;
        right: 52px;
    }
}