/* ============================================================
   Calorie Calculator – Productivity Tools
   Prefix: --tc-
   Only tool-specific styles. Shared styles come from common.css.
   ============================================================ */

/* ----- CSS Custom Properties ----- */
:root {
    --tc-primary: #FF8C00;
    --tc-primary-hover: #E67E00;
    --tc-primary-light: rgba(255, 140, 0, 0.10);
    --tc-primary-border: rgba(255, 140, 0, 0.25);

    --tc-gray-50: #f8fafc;
    --tc-gray-100: #f1f5f9;
    --tc-gray-200: #e2e8f0;
    --tc-gray-300: #cbd5e1;
    --tc-gray-400: #94a3b8;
    --tc-gray-500: #64748b;
    --tc-gray-600: #475569;
    --tc-gray-700: #334155;
    --tc-gray-800: #1e293b;
    --tc-gray-900: #0f172a;

    --tc-radius-lg: 16px;
    --tc-radius-md: 8px;
    --tc-radius-sm: 6px;

    --tc-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --tc-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    --tc-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Semantic colors */
    --tc-loss: #ef4444;
    --tc-loss-light: rgba(239, 68, 68, 0.08);
    --tc-maintain: #22c55e;
    --tc-maintain-light: rgba(34, 197, 94, 0.08);
    --tc-gain: #3b82f6;
    --tc-gain-light: rgba(59, 130, 246, 0.08);

    /* Macro colors */
    --tc-protein: #ef4444;
    --tc-carbs: #f59e0b;
    --tc-fat: #3b82f6;

    --tc-transition: 0.2s ease;
}

/* ----- Tool Page Container ----- */
.tool-page-container {
    margin-top: 0;
    margin-bottom: 5rem;
}

/* ----- History Card Spacing ----- */
.tc-history-card {
    margin-top: 1.5rem;
}

/* ----- Options Bar ----- */
.options-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--tc-gray-200);
    background: var(--tc-gray-50);
    gap: 12px;
}

.options-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.option-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.option-inline-label {
    font-family: var(--tc-font);
    font-size: 11px;
    font-weight: 700;
    color: var(--tc-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.select-inline {
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--tc-gray-200);
    border-radius: var(--tc-radius-sm);
    font-family: var(--tc-font);
    font-size: 12px;
    font-weight: 600;
    color: var(--tc-gray-700);
    background: #fff;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color var(--tc-transition);
}

.select-inline:focus {
    border-color: var(--tc-primary);
}

/* Full-width select for activity level */
.select-full {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--tc-gray-200);
    border-radius: var(--tc-radius-md);
    background: var(--tc-gray-50);
    font-family: var(--tc-font);
    font-size: 14px;
    font-weight: 500;
    color: var(--tc-gray-900);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color var(--tc-transition), box-shadow var(--tc-transition);
}

.select-full:focus {
    border-color: var(--tc-primary);
    box-shadow: 0 0 0 3px var(--tc-primary-light);
}

/* Real-time Badge */
.options-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.realtime-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--tc-font);
    font-size: 12px;
    font-weight: 500;
    color: var(--tc-gray-500);
    white-space: nowrap;
}

.realtime-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tc-maintain);
    animation: tc-pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes tc-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50%      { opacity: 0.7; box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
}

/* ----- Calculator Grid ----- */
.calc-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    min-height: 0;
}

.calc-input-panel,
.calc-result-panel {
    min-width: 0;
    overflow: hidden;
}

.calc-input-panel {
    border-right: 1px solid var(--tc-gray-200);
}

/* ----- Panel Header ----- */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--tc-gray-200);
    gap: 12px;
}

.panel-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.panel-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.panel-label {
    font-family: var(--tc-font);
    font-size: 16px;
    font-weight: 700;
    color: var(--tc-gray-900);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-label iconify-icon {
    color: var(--tc-primary);
}

.panel-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    background: var(--tc-primary-light);
    color: var(--tc-primary);
    font-family: var(--tc-font);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.panel-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid var(--tc-gray-200);
    border-radius: var(--tc-radius-sm);
    background: #fff;
    color: var(--tc-gray-600);
    font-family: var(--tc-font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--tc-transition), color var(--tc-transition), border-color var(--tc-transition);
    white-space: nowrap;
}

.panel-action-btn:hover {
    background: var(--tc-gray-50);
    border-color: var(--tc-gray-300);
    color: var(--tc-gray-800);
}

.panel-action-btn.primary {
    background: var(--tc-primary);
    color: #fff;
    border-color: var(--tc-primary);
}

.panel-action-btn.primary:hover {
    background: var(--tc-primary-hover);
    border-color: var(--tc-primary-hover);
}

/* ----- Calc Inputs ----- */
.calc-inputs {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    font-family: var(--tc-font);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tc-gray-500);
    display: flex;
    align-items: center;
    gap: 6px;
}

.optional-tag {
    font-size: 10px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--tc-gray-400);
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity var(--tc-transition), max-height 0.3s ease;
    max-height: 200px;
    overflow: hidden;
    opacity: 1;
}

.input-row.hidden {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    margin: 0;
    overflow: hidden;
}

.input-field {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.input-field input {
    width: 100%;
    padding: 10px 14px;
    padding-right: 48px;
    border: 1px solid var(--tc-gray-200);
    border-radius: var(--tc-radius-md);
    background: var(--tc-gray-50);
    font-family: var(--tc-font);
    font-size: 15px;
    font-weight: 500;
    color: var(--tc-gray-900);
    outline: none;
    transition: border-color var(--tc-transition), background var(--tc-transition), box-shadow var(--tc-transition);
    -moz-appearance: textfield;
}

.input-field input::-webkit-outer-spin-button,
.input-field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-field input::placeholder {
    color: var(--tc-gray-400);
    font-weight: 400;
}

.input-field input:focus {
    border-color: var(--tc-primary);
    background: #fff;
    box-shadow: 0 0 0 3px var(--tc-primary-light);
}

.input-unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--tc-gray-200);
    font-family: var(--tc-font);
    font-size: 11px;
    font-weight: 600;
    color: var(--tc-gray-500);
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

/* Gender Toggle */
.gender-toggle {
    display: flex;
    gap: 8px;
    width: 100%;
}

.gender-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px solid var(--tc-gray-200);
    border-radius: var(--tc-radius-md);
    background: var(--tc-gray-50);
    color: var(--tc-gray-600);
    font-family: var(--tc-font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--tc-transition), color var(--tc-transition), border-color var(--tc-transition), box-shadow var(--tc-transition);
}

.gender-btn:hover {
    border-color: var(--tc-gray-300);
    background: #fff;
}

.gender-btn.active {
    border-color: var(--tc-primary);
    background: var(--tc-primary-light);
    color: var(--tc-primary);
    box-shadow: 0 0 0 3px var(--tc-primary-light);
    font-weight: 600;
}

/* ----- Result Content ----- */
.result-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Calorie Score Section */
.tdee-score-section {
    text-align: center;
    padding: 20px 0 8px;
}

.tdee-label-small {
    font-family: var(--tc-font);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tc-gray-400);
    margin-bottom: 8px;
}

.tdee-score {
    font-family: var(--tc-font);
    font-size: 56px;
    font-weight: 800;
    color: var(--tc-gray-900);
    line-height: 1;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

.tdee-score.has-value {
    color: var(--tc-primary);
}

.tdee-sublabel {
    font-family: var(--tc-font);
    font-size: 14px;
    font-weight: 500;
    color: var(--tc-gray-400);
}

/* Info Cards */
.info-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.info-card {
    padding: 14px;
    border-radius: var(--tc-radius-md);
    background: var(--tc-gray-50);
    border: 1px solid var(--tc-gray-200);
    text-align: center;
    transition: border-color var(--tc-transition), box-shadow var(--tc-transition);
}

.info-card:hover {
    border-color: var(--tc-gray-300);
    box-shadow: var(--tc-shadow);
}

.info-card-label {
    font-family: var(--tc-font);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tc-gray-400);
    margin-bottom: 6px;
}

.info-card-value {
    font-family: var(--tc-font);
    font-size: 16px;
    font-weight: 700;
    color: var(--tc-gray-900);
}

/* ----- Calorie Targets ----- */
.targets-section {
    border-top: 1px solid var(--tc-gray-200);
    padding-top: 20px;
}

.targets-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--tc-font);
    font-size: 14px;
    font-weight: 700;
    color: var(--tc-gray-800);
    margin-bottom: 14px;
}

.targets-title iconify-icon {
    color: var(--tc-primary);
}

.targets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.target-card {
    padding: 12px;
    border-radius: var(--tc-radius-md);
    border: 1px solid var(--tc-gray-200);
    text-align: center;
    transition: border-color var(--tc-transition), box-shadow var(--tc-transition);
}

.target-card:hover {
    box-shadow: var(--tc-shadow);
}

.target-card.target-loss {
    background: var(--tc-loss-light);
    border-color: rgba(239, 68, 68, 0.15);
}

.target-card.target-maintain {
    background: var(--tc-maintain-light);
    border-color: rgba(34, 197, 94, 0.15);
}

.target-card.target-gain {
    background: var(--tc-gain-light);
    border-color: rgba(59, 130, 246, 0.15);
}

.target-label {
    font-family: var(--tc-font);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tc-gray-600);
    margin-bottom: 2px;
}

.target-desc {
    font-family: var(--tc-font);
    font-size: 10px;
    font-weight: 400;
    color: var(--tc-gray-400);
    margin-bottom: 8px;
}

.target-value {
    font-family: var(--tc-font);
    font-size: 18px;
    font-weight: 800;
    color: var(--tc-gray-900);
}

.target-loss .target-value { color: var(--tc-loss); }
.target-maintain .target-value { color: var(--tc-maintain); }
.target-gain .target-value { color: var(--tc-gain); }

/* ----- Macros Section ----- */
.macros-section {
    border-top: 1px solid var(--tc-gray-200);
    padding-top: 20px;
}

.macro-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.macro-tab {
    padding: 6px 14px;
    border: 1px solid var(--tc-gray-200);
    border-radius: 9999px;
    background: #fff;
    font-family: var(--tc-font);
    font-size: 12px;
    font-weight: 500;
    color: var(--tc-gray-500);
    cursor: pointer;
    transition: all var(--tc-transition);
    white-space: nowrap;
}

.macro-tab:hover {
    border-color: var(--tc-gray-300);
    color: var(--tc-gray-700);
}

.macro-tab.active {
    background: var(--tc-primary);
    border-color: var(--tc-primary);
    color: #fff;
    font-weight: 600;
}

/* Macro Bars */
.macro-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.macro-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.macro-bar-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--tc-font);
    font-size: 13px;
    font-weight: 600;
    color: var(--tc-gray-700);
    width: 80px;
    flex-shrink: 0;
}

.macro-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.macro-dot-protein { background: var(--tc-protein); }
.macro-dot-carbs   { background: var(--tc-carbs); }
.macro-dot-fat     { background: var(--tc-fat); }

.macro-bar-track {
    flex: 1;
    height: 10px;
    background: var(--tc-gray-100);
    border-radius: 5px;
    overflow: hidden;
}

.macro-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.macro-fill-protein { background: var(--tc-protein); }
.macro-fill-carbs   { background: var(--tc-carbs); }
.macro-fill-fat     { background: var(--tc-fat); }

.macro-bar-value {
    font-family: var(--tc-font);
    font-size: 13px;
    font-weight: 700;
    color: var(--tc-gray-800);
    width: 60px;
    text-align: right;
    flex-shrink: 0;
}

.macro-split-label {
    text-align: center;
    font-family: var(--tc-font);
    font-size: 12px;
    font-weight: 500;
    color: var(--tc-gray-400);
    margin-top: 10px;
}

/* ----- Formula Comparison Table ----- */
.formula-section {
    border-top: 1px solid var(--tc-gray-200);
    padding-top: 20px;
}

.formula-table-wrapper {
    overflow-x: auto;
    border-radius: 0.75rem;
    border: 1px solid var(--tc-gray-200);
    background: #fff;
}

.formula-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--tc-font);
    font-size: 13px;
}

.formula-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    background: var(--tc-gray-900);
    border-bottom: 2px solid var(--tc-gray-200);
}

.formula-table th:first-child {
    border-top-left-radius: 0.625rem;
}

.formula-table th:last-child {
    border-top-right-radius: 0.625rem;
}

.formula-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--tc-gray-100);
    color: var(--tc-gray-700);
}

.formula-table tbody tr:hover {
    background: var(--tc-gray-50);
}

.formula-table tbody tr:last-child td {
    border-bottom: none;
}

.formula-table tbody tr.active-formula {
    background: var(--tc-primary-light);
}

.formula-table tbody tr.active-formula td {
    font-weight: 600;
    color: var(--tc-gray-900);
}

/* ----- History Panel ----- */
.history-body {
    padding: 16px 24px 24px;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 12px;
    color: var(--tc-gray-400);
    font-family: var(--tc-font);
    font-size: 13px;
    font-weight: 500;
}

.history-empty iconify-icon {
    font-size: 48px;
    color: var(--tc-gray-300);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    border-radius: var(--tc-radius-md);
    background: var(--tc-gray-50);
    border: 1px solid var(--tc-gray-200);
    transition: border-color var(--tc-transition), box-shadow var(--tc-transition);
    gap: 6px;
}

.history-item:hover {
    border-color: var(--tc-gray-300);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.history-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-date {
    font-family: var(--tc-font);
    font-size: 11px;
    font-weight: 500;
    color: var(--tc-gray-400);
}

.history-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--tc-gray-400);
    cursor: pointer;
    transition: background var(--tc-transition), color var(--tc-transition);
}

.history-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--tc-loss);
}

.history-item-body {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.history-tdee {
    font-family: var(--tc-font);
    font-size: 18px;
    font-weight: 700;
    color: var(--tc-primary);
}

.history-bmr {
    font-family: var(--tc-font);
    font-size: 13px;
    font-weight: 500;
    color: var(--tc-gray-500);
}

.history-item-details {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-family: var(--tc-font);
    font-size: 12px;
    color: var(--tc-gray-400);
}

/* ----- Toast Notifications ----- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: var(--tc-radius-md);
    background: var(--tc-gray-800);
    color: #fff;
    font-family: var(--tc-font);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--tc-shadow-lg);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 360px;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.toast-hiding {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
}

.toast-success { background: var(--tc-maintain); }
.toast-error   { background: var(--tc-loss); }

/* ----- Responsive: 1024px ----- */
@media (max-width: 1024px) {
    .calc-grid {
        grid-template-columns: 1fr;
    }

    .calc-input-panel {
        border-right: none;
        border-bottom: 1px solid var(--tc-gray-200);
    }
}

/* ----- Responsive: 768px ----- */
@media (max-width: 768px) {
    .options-bar {
        padding: 12px 16px;
    }

    .panel-header {
        padding: 14px 16px;
    }

    .calc-inputs {
        padding: 20px 16px;
    }

    .result-content {
        padding: 20px 16px;
    }

    .history-body {
        padding: 14px 16px 20px;
    }

    .panel-action-btn span {
        display: none;
    }

    .panel-action-btn {
        padding: 6px 8px;
    }

    .tdee-score {
        font-size: 48px;
    }

    .info-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .info-card {
        padding: 10px 8px;
    }

    .info-card-value {
        font-size: 14px;
    }

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

/* ----- Responsive: 600px ----- */
@media (max-width: 600px) {
    .options-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .options-bar-left {
        width: 100%;
        flex-direction: column;
    }

    .option-inline {
        width: 100%;
    }

    .select-inline {
        flex: 1;
    }

    .realtime-badge {
        justify-content: center;
    }

    .tdee-score {
        font-size: 42px;
    }

    .info-cards {
        grid-template-columns: 1fr;
    }

    .targets-grid {
        grid-template-columns: 1fr;
    }

    .macro-tabs {
        gap: 4px;
    }

    .macro-tab {
        padding: 5px 10px;
        font-size: 11px;
    }

    .macro-bar-label {
        width: 65px;
        font-size: 12px;
    }

    .macro-bar-value {
        width: 50px;
        font-size: 12px;
    }

    .history-item-main {
        flex-wrap: wrap;
        gap: 6px 14px;
    }
}
