/* ============================================
   AI TOOLCOR — TOOL PAGE STYLES
   tool.css · v3.0
   Works with common.css v3.0 (aliases included)
   ============================================ */

/* ============================================
   TOOL HERO
   ============================================ */
.tool-hero {
    padding: calc(var(--nav-h) + 22px) 24px 28px;
    background: var(--gradient-hero);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.tool-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 55% 45% at 20% 80%, rgba(124,58,237,0.06) 0%, transparent 70%),
        radial-gradient(ellipse 50% 50% at 80% 20%, rgba(14,165,233,0.06) 0%, transparent 70%);
    pointer-events: none;
}

.tool-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.tool-breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.tool-breadcrumb a:hover { color: var(--primary-dark); }

.tool-breadcrumb i {
    font-size: 0.62rem;
    color: var(--text-muted);
}

.tool-hero-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 1;
}

.tool-hero h1 {
    font-size: clamp(1.5rem, 3.5vw, 2.1rem);
    font-weight: 900;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    position: relative;
    z-index: 1;
}

.tool-hero p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto;
    line-height: 1.65;
    position: relative;
    z-index: 1;
}

/* ============================================
   TOOL CONTAINER
   ============================================ */
.tool-container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 24px;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
}

/* ============================================
   INPUT CARD
   ============================================ */
.tool-card-main {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-md);
}

.tool-card-main h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.tool-card-main h2 i { color: var(--primary); }

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group { margin-bottom: 22px; }

.form-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-label .label-value {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
}

.form-input-wrapper { position: relative; }

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    outline: none;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124,58,237,0.1);
    background: var(--bg-secondary);
}

/* date input colour fix */
.form-input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.5;
    cursor: pointer;
}

.form-input-prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
}

.form-input.with-prefix { padding-left: 35px; }

.form-input-suffix {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
    font-size: 0.85rem;
}

.form-input.with-suffix { padding-right: 50px; }

/* ===== Range Slider ===== */
.form-range {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin-top: 12px;
    cursor: pointer;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: var(--gradient-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-glow);
}

.form-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--gradient-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Radio / Tab group ===== */
.radio-group {
    display: flex;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 4px;
}

.radio-group input[type="radio"] { display: none; }

.radio-group label {
    flex: 1;
    padding: 9px 14px;
    text-align: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
}

.radio-group input[type="radio"]:checked + label {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    flex: 1;
    padding: 13px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

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

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}

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

/* ============================================
   RESULT CARD
   ============================================ */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: calc(var(--nav-h) + 16px);
}

.result-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.result-card h2 i { color: var(--accent); }

/* Main display */
.result-main {
    text-align: center;
    padding: 22px 20px;
    background: var(--gradient-hero);
    border-radius: var(--radius-lg);
    margin-bottom: 18px;
    border: 1px solid var(--border);
}

.result-main-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 6px;
}

.result-main-value {
    font-size: 2.2rem;
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.result-main-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Breakdown grid */
.result-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.result-item {
    background: var(--bg-primary);
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    text-align: center;
    transition: var(--transition);
}

.result-item:hover { border-color: var(--primary-light); }

.result-item-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.result-item-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.result-item.highlight .result-item-value { color: var(--primary); }
.result-item.danger  .result-item-value  { color: #ef4444; }
.result-item.success .result-item-value  { color: #10b981; }

/* Chart / info block */
.result-chart {
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.chart-bar {
    height: 28px;
    background: var(--border);
    border-radius: 50px;
    overflow: hidden;
    display: flex;
    margin-bottom: 12px;
    position: relative;
}

.chart-bar-segment {
    height: 100%;
    transition: width 0.6s ease;
}

.chart-legend {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.78rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.legend-color {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Action buttons (copy/share/print) */
.result-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.action-btn {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.action-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: rgba(124,58,237,0.05);
}

/* Empty state */
.result-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.result-empty i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: var(--border);
    display: block;
}

.result-empty p { font-size: 0.9rem; }

/* ============================================
   INFO SECTION
   ============================================ */
.info-section {
    max-width: 900px;
    margin: 32px auto;
    padding: 0 24px;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

.info-card h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 18px 0 8px;
    color: var(--text-primary);
}

.info-card p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.info-card ul,
.info-card ol {
    color: var(--text-secondary);
    padding-left: 22px;
    line-height: 1.8;
    margin-bottom: 16px;
}

.info-card ul li,
.info-card ol li {
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.info-card strong { color: var(--text-primary); font-weight: 700; }

.info-formula {
    background: var(--bg-primary);
    border-left: 4px solid var(--primary);
    padding: 14px 18px;
    margin: 14px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow-x: auto;
}

.info-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.info-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.info-feature i { color: var(--primary); font-size: 0.85rem; }

/* ============================================
   RELATED TOOLS
   ============================================ */
.related-tools {
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 24px;
}

.related-tools h2 {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* 6 cards → 3-col grid (never 5-col which leaves an awkward 6th) */
.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

/* If there are exactly 4 or 5 cards on wider screens, auto-fill looks better */
@media (min-width: 900px) {
    .related-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

.related-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: var(--shadow-xs);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.related-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s var(--ease);
}

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

.related-card:hover::before { transform: scaleX(1); }

.related-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
    transition: transform 0.25s var(--ease);
}

.related-card:hover .related-card-icon { transform: scale(1.1) rotate(-3deg); }

.related-card-text {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .tool-grid {
        grid-template-columns: 1fr;
    }
    .result-card {
        position: static;
    }
    .related-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .tool-hero    { padding: calc(var(--nav-h) + 12px) 16px 22px; }
    .tool-container { padding: 0 16px; }
    .tool-card-main,
    .result-card  { padding: 22px 18px; }
    .info-card    { padding: 20px 16px; }

    .result-main-value { font-size: 1.85rem; }
    .result-breakdown  { grid-template-columns: 1fr 1fr; }

    .btn-group { flex-direction: column; }
    .info-section,
    .related-tools { padding: 0 16px; }
}

@media (max-width: 600px) {
    .related-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .tool-hero-icon { width: 48px; height: 48px; font-size: 1.2rem; }
    .related-card   { padding: 16px 10px; }
}

@media (max-width: 480px) {
    .tool-hero h1  { font-size: 1.4rem; }
    .tool-card-main,
    .result-card   { padding: 18px 14px; }
    .result-main-value { font-size: 1.6rem; }
    .form-input    { font-size: 0.95rem; }
    .result-breakdown { grid-template-columns: 1fr 1fr; }
    .btn-group { flex-direction: column; }
}

@media (max-width: 380px) {
    .related-grid { grid-template-columns: 1fr 1fr; }
}