/* ===================================
   Fasting Tracker - Custom Styles
   =================================== */

/* --- CSS Custom Properties --- */
:root,
[data-bs-theme="light"] {
    --ft-bg: #f0f2f5;
    --ft-card-bg: #ffffff;
    --ft-card-border: rgba(0, 0, 0, 0.06);
    --ft-navbar-bg: #1a1d23;
    --ft-accent: #6366f1;
    --ft-accent-hover: #4f46e5;
    --ft-accent-subtle: rgba(99, 102, 241, 0.08);
    --ft-orange: #f97316;
    --ft-green: #22c55e;
    --ft-timer-color: #1a1d23;
    --ft-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --ft-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --ft-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --ft-ring-track: #e9ecef;
    --ft-footer-border: #e5e7eb;
    --ft-stat-label: #6b7280;
}

[data-bs-theme="dark"] {
    --ft-bg: #0f1117;
    --ft-card-bg: #1a1d27;
    --ft-card-border: rgba(255, 255, 255, 0.06);
    --ft-navbar-bg: #0f1117;
    --ft-accent: #818cf8;
    --ft-accent-hover: #6366f1;
    --ft-accent-subtle: rgba(129, 140, 248, 0.1);
    --ft-orange: #fb923c;
    --ft-green: #4ade80;
    --ft-timer-color: #f1f5f9;
    --ft-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --ft-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --ft-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --ft-ring-track: #2a2d37;
    --ft-footer-border: #2a2d37;
    --ft-stat-label: #9ca3af;
}

/* --- Base --- */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--ft-bg) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

footer {
    margin-top: auto !important;
}

/* --- Cards --- */
.card {
    background-color: var(--ft-card-bg);
    border: 1px solid var(--ft-card-border);
    border-radius: 0.75rem;
    box-shadow: var(--ft-shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--ft-card-border);
    font-weight: 600;
}

/* --- Navbar --- */
.ft-navbar {
    background-color: var(--ft-navbar-bg) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    padding: 0.75rem 0;
}

.ft-navbar .navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.ft-navbar .nav-link {
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: 0.5rem;
    transition: background-color 0.15s ease;
}

.ft-navbar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* --- Theme Toggle --- */
.theme-toggle {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 0.5rem;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* --- Buttons --- */
.btn-accent {
    background-color: var(--ft-accent);
    border-color: var(--ft-accent);
    color: #fff;
}

.btn-accent:hover {
    background-color: var(--ft-accent-hover);
    border-color: var(--ft-accent-hover);
    color: #fff;
}

.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

/* --- Auth Pages --- */
.auth-wrapper {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: 1rem;
    box-shadow: var(--ft-shadow-lg);
    overflow: hidden;
}

.auth-card .card-body {
    padding: 2.5rem;
}

.auth-brand {
    width: 56px;
    height: 56px;
    border-radius: 1rem;
    background: linear-gradient(135deg, var(--ft-accent), var(--ft-orange));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 1.5rem;
    color: #fff;
}

/* --- Progress Ring --- */
.progress-ring-container {
    position: relative;
    display: inline-block;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    stroke: var(--ft-ring-track);
}

.progress-ring-fill {
    transition: stroke-dashoffset 1s ease-in-out;
    filter: drop-shadow(0 0 6px currentColor);
}

.progress-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

/* --- Plan cards --- */
.plan-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.plan-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ft-shadow-lg) !important;
}

.plan-card .plan-time-bar .d-flex {
    border-radius: 0.5rem;
}

/* --- Timer --- */
#liveTimer {
    letter-spacing: 2px;
    color: var(--ft-timer-color);
}

/* --- Idle state animation --- */
.timer-idle i {
    animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.08); }
}

/* --- Status indicator dot --- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    animation: glow 2s ease-in-out infinite;
}

.status-dot.fasting { background-color: var(--ft-orange); }
.status-dot.eating  { background-color: var(--ft-green); }

@keyframes glow {
    0%, 100% { box-shadow: 0 0 4px currentColor; }
    50%      { box-shadow: 0 0 12px currentColor; }
}

/* --- Session card accent border --- */
.session-card-fasting {
    border-top: 3px solid var(--ft-orange);
}

.session-card-eating {
    border-top: 3px solid var(--ft-green);
}

/* --- Stats grid --- */
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ft-accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--ft-stat-label);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Footer --- */
.ft-footer {
    border-top: 1px solid var(--ft-footer-border);
    background: transparent;
    transition: border-color 0.3s ease;
}

/* --- History table --- */
.ft-table {
    --bs-table-bg: transparent;
}

.ft-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ft-stat-label);
    border-bottom-width: 1px;
}

/* --- Smooth transitions --- */
.card, .btn, .alert, .badge, .nav-link, .table, .form-control, .input-group-text {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.2s ease;
}

/* --- Page heading --- */
.page-heading {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* --- Welcome banner --- */
.welcome-banner {
    background: linear-gradient(135deg, var(--ft-accent), #8b5cf6);
    color: #fff;
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.welcome-banner a {
    color: #fff;
    text-decoration: underline;
}
