/* Reset standard browser spacing */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: #111; /* Deep Black */
    color: #fff;
    display: flex;
    justify-content: center;
    padding-top: 50px;
}

.container {
    width: 100%;
    max-width: 400px; /* Mobile width */
    padding: 20px;
    padding-bottom: 80px; /* Extra space at bottom */
}

/* --- NO SPINNERS (The Fix) --- */
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
/* Firefox */
input[type="number"] {
    -moz-appearance: textfield; /* Vendor prefix */
    appearance: textfield;      /* Standard property */
  }

/* HEADER & TOGGLE */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

h1 {
    font-size: 2rem;
    letter-spacing: -1px;
    margin: 0;
}

.mode-switch {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-btn {
    background: none;
    border: none;
    color: #444; 
    font-size: 0.9rem;
    padding: 5px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

.mode-btn:hover { color: #888; }

.mode-btn.active {
    color: #fff; 
    border-bottom: 2px solid #fff; 
}

.divider {
    color: #333;
    font-weight: 300;
}

header { margin-bottom: 10px; }

/* DATE NAVIGATION */
.date-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 5px;
}

.nav-btn {
    background: transparent;
    color: #666;
    border: 1px solid #333;
    padding: 5px 10px;
    font-size: 1rem;
    border-radius: 4px;
}

.nav-btn:hover {
    background: #333;
    color: #fff;
    border-color: #fff;
}

#current-date-display {
    color: #888;
    font-size: 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    min-width: 120px; 
    text-align: center;
}

/* DASHBOARD & GOALS */
.total-display {
    background: #222;
    padding: 20px 15px; /* Compact padding */
    border-radius: 12px;
    text-align: center;
    margin-bottom: 15px; /* Tighter margin */
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center everything */
    gap: 10px;
}

.main-total {
    margin-top: 0;
    width: 100%;
}

.main-total span {
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: #888;
    text-transform: uppercase;
}

#total-cal {
    font-size: 3.5rem;
    margin: 5px 0 0 0;
    color: #fff;
    line-height: 1;
}

.goal-text {
    color: #555;
    font-size: 1.2rem;
    font-weight: 400;
    margin-left: 5px;
    vertical-align: middle;
}

/* FIX: Button is now static (stacked), borderless, and centered */
#edit-goals-btn {
    position: static; /* No longer absolute */
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: #555;
    font-size: 0.75rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    padding: 10px;
    margin-bottom: 5px;
    transition: color 0.2s;
}

#edit-goals-btn:hover {
    color: #fff;
    background: transparent;
}

/* FORM STYLES */
#goals-form {
    width: 100%;
    margin-bottom: 10px;
    border-top: 1px dashed #333;
    padding-top: 15px;
}

.goal-grid {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.goal-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.goal-label {
    font-size: 0.65rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.goal-input {
    width: 100%;
    text-align: center;
    background: #151515;
    border: 1px solid #333;
    padding: 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}

/* Color Coding Inputs */
.c-p { color: #4ade80; } 
.c-c { color: #60a5fa; } 
.c-f { color: #f87171; } 

.input-p:focus { border-color: #4ade80; outline: none; }
.input-c:focus { border-color: #60a5fa; outline: none; }
.input-f:focus { border-color: #f87171; outline: none; }

/* MACRO BARS */
.macro-row {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.macro-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.macro-stat .label {
    color: #666;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.macro-stat .val {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
}

.macro-goal {
    color: #444;
    font-size: 0.75rem;
    font-weight: 400;
    margin-left: 2px;
}

.progress-bg {
    background: #333;
    height: 4px;
    width: 100%;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease;
}

.fill-p { background: #4ade80; }
.fill-c { background: #60a5fa; }
.fill-f { background: #f87171; }

#total-p { color: #4ade80; } 
#total-c { color: #60a5fa; } 
#total-f { color: #f87171; } 

/* INPUTS & CREATOR */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

select {
    background: #222;
    border: none;
    padding: 15px;
    color: white;
    border-radius: 8px;
    width: 100%;
    outline: none;
    appearance: none;
    cursor: pointer;
    font-size: 1rem;
}

input {
    background: #222;
    border: none;
    padding: 15px;
    color: white;
    border-radius: 8px;
    width: 100%;
    outline: none;
}

::placeholder { 
    text-transform: lowercase; 
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* Button Reset */
button {
    background: #fff;
    color: #000;
    border: none;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

button:hover { background: #ccc; }

/* FEED CARDS */
.entry-card {
    background: #222;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid #fff;
    animation: fadeIn 0.3s ease;
    min-height: 45px;
}

.entry-text { font-weight: 600; }
.entry-value { color: #888; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-left {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.delete-btn {
    background: transparent;
    color: #444;
    font-size: 1.5rem;
    padding: 0 10px;
    margin-left: 10px;
}

.delete-btn:hover {
    color: red; 
    background: transparent;
}

.action-bar {
    text-align: right;
    margin-bottom: 5px;
}

.text-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
}
.text-btn:hover { color: #fff; }

.creator-panel {
    background: #1a1a1a;
    border: 1px dashed #444;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.hidden { display: none; }

.creator-panel h3 {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.macro-inputs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.calc-preview {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #888;
    text-align: right;
}

#calc-calories {
    color: #fff;
    font-weight: bold;
}

.save-btn {
    width: 100%;
    margin-top: 15px;
    background: #333;
    color: #fff;
}
.save-btn:hover { background: #444; }

.library-section {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.library-section h4 {
    font-size: 0.7rem;
    color: #666;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.lib-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #222;
    font-size: 0.9rem;
}

.lib-name { color: #ccc; }

.lib-delete {
    color: #666;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
}
.lib-delete:hover { color: #f87171; }

.input-group-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.input-group-row input { min-width: 0; }

.card-stats {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 0.85rem;
    color: #888;
}

.card-stats > span:first-child {
    display: inline-block;
    width: 55px; 
    text-align: right; 
    margin-right: 8px; 
}

.macro-group {
    display: flex;
    gap: 8px; 
    font-style: italic;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
}

.macro-group::before {
    content: ":";       
    margin-right: 6px;  
    color: #444;       
    font-style: normal; 
    font-weight: 400;
}

.macro-tag {
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.tag-p { color: #4ade80; } 
.tag-c { color: #60a5fa; } 
.tag-f { color: #f87171; } 

/* MOBILE & UTILS */
html, body {
    overflow-x: hidden;
    touch-action: manipulation; 
}

@media screen and (max-width: 768px) {
    input, select, button {
        font-size: 16px !important; 
    }
    .delete-btn {
        padding: 10px 15px; 
    }
}

#new-unit {
    background-color: #333; 
    border: 1px solid #555; 
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    padding-right: 25px; 
}
#new-unit:hover {
    background-color: #444; 
    border-color: #888;
}

/* --- TRAIN VIEW STYLES --- */
.section-title {
    text-align: center;
    color: #666;
    font-size: 0.8rem;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.split-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 15px;
}

.split-btn {
    background: #222;
    border: 1px solid #333;
    color: #fff;
    padding: 30px 10px; 
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.split-btn:hover {
    background: #fff;
    color: #000;
    border-color: #fff;
}

.split-btn.completed {
    border-color: #4ade80; 
    color: #4ade80;        
    background: #111;      
    position: relative;
}

.split-btn.completed::after {
    content: "✓";
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1rem;
}

/* --- NEW CENTERED HEADER --- */
.workout-header {
    position: relative;     /* Allows absolute positioning for the arrow */
    display: flex;
    justify-content: center; /* Centers the title */
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 0;
    border-bottom: none;    /* Removed divider line */
    min-height: 40px;
}

#active-split-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    margin: 0;
    letter-spacing: 1px;
}

/* --- STEALTH BACK BUTTON --- */
#back-to-split {
    position: absolute;     /* Pins it to the left */
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #444; 
    font-size: 1.5rem;      /* Bigger arrow */
    padding: 10px;          /* Easy to tap */
    font-weight: 400;
}

#back-to-split:hover {
    color: #fff;
    background: transparent;
    border: none;
}

/* --- COMPACT EXERCISE CARD --- */
.exercise-card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px;          
    margin-bottom: 10px;    
}

.ex-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;     
}

.ex-name {
    font-weight: 700;
    font-size: 0.9rem;      
    color: #fff;
    display: block;
}

.ex-history {
    font-size: 0.7rem;      
    color: #666; 
    font-family: monospace;
    margin-top: 2px;        
    display: block;
}

/* FIXED ALIGNMENT FOR INPUT ROW */
.set-input-row {
    display: flex;
    gap: 8px;               
    margin-top: 8px;        
    align-items: stretch; 
}

/* --- SLIMMER INPUTS --- */
.set-input-row input {
    background: #000;
    border: 1px solid #333;
    padding: 8px;           
    text-align: center;
    font-size: 0.9rem;      
    color: #fff;
    border-radius: 6px;
    width: auto; 
    min-width: 0;
    height: 40px;           
}

.log-set-btn {
    background: #333;
    color: #fff;
    padding: 0;             
    width: 40px;            
    height: 40px;           
    font-size: 1.2rem; 
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.log-set-btn:hover { 
    background: #4ade80; 
    color: #000; 
}

.today-logs {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #333;
}

/* --- TIGHTER LOGS --- */
.mini-log {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;      
    color: #aaa;
    margin-bottom: 2px;     
    padding: 4px 8px;       
    background: #111;
    border-radius: 4px;
    min-height: 28px;       
}

.mini-delete {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.2rem;      
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    height: 100%; 
    line-height: 1;
}
.mini-delete:hover { color: #f87171; }

#finish-workout-btn {
    width: 100%;
    margin-top: 20px; /* TIGHTENED: Was 30px */
    background: #fff;
    color: #000;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 15px;
    border-radius: 8px;
}
#finish-workout-btn:hover {
    background: #4ade80; 
    color: #000;
}

/* LOCKED STATE */
.set-input-row input:disabled {
    background: #111;
    color: #444; 
    border-color: transparent;
    cursor: not-allowed;
}

.hidden-visibility {
    display: none !important; 
}

#unlock-workout-btn {
    width: 100%;
    margin-top: 30px;
    background: #222;
    color: #666;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 1px;
    padding: 15px;
    border: 1px solid #333;
    border-radius: 8px;
    cursor: pointer;
}
#unlock-workout-btn:hover {
    background: #333;
    color: #fff;
    border-color: #fff;
}

.log-set-btn.locked-indicator {
    background: #111;      
    color: #4ade80;        
    border: 1px solid #333; 
    cursor: default;       
}
.log-set-btn.locked-indicator:hover {
    background: #111;      
    color: #4ade80;
}

/* --- AUTH GATE --- */
#auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #111;
    z-index: 9999; /* Sit on top of everything */
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-box {
    width: 100%;
    max-width: 320px;
    text-align: center;
    padding: 20px;
}

.auth-box h1 {
    font-size: 3rem;
    margin-bottom: 5px;
    letter-spacing: -2px;
}

.auth-box p {
    color: #666;
    font-size: 0.8rem;
    margin-bottom: 30px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.auth-box input {
    margin-bottom: 10px;
    background: #222;
    border: 1px solid #333;
    text-align: center;
}

.auth-box button {
    width: 100%;
    background: #fff;
    color: #000;
    margin-top: 10px;
}

#auth-msg {
    margin-top: 15px;
    color: #f87171;
    font-size: 0.8rem;
    min-height: 20px;
}

/* Helper to hide the gate once logged in */
.hidden { display: none !important; }

/* --- HEADER ALIGNMENT --- */
.header-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Pushes content to the right */
    gap: 4px;
}

.greeting-text {
    font-size: 0.7rem; 
    color: #666; 
    letter-spacing: 1px; 
    text-transform: uppercase; 
    margin-top: -5px; 
    margin-bottom: 5px;
}

.logout-link {
    background: none; 
    border: none; 
    padding: 0; 
    color: #f87171; /* Subtle red */
    font-size: 0.55rem; 
    cursor: pointer; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    margin-right: 2px; /* Slight alignment tweak */
}
.logout-link:hover { text-decoration: underline; }

/* --- BODY VIEW --- */
.weight-card {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.weight-val {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.weight-date {
    font-size: 0.8rem;
    color: #666;
    letter-spacing: 1px;
}

/* COACH SELECTOR (Ghost Mode) */
#coach-selector {
    appearance: none;          /* Removes default browser arrow */
    -webkit-appearance: none;  /* Safari fix */
    -moz-appearance: none;     /* Firefox fix */
    
    background: transparent;
    border: none;              /* No box */
    color: #4ade80;            /* Matrix Green */
    
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    outline: none;
    
    text-align: right;         /* Aligns text to the right */
    direction: rtl;            /* Forces the text to stick to the right edge */
    padding: 0;
    margin-bottom: 5px;
}

#coach-selector:hover {
    text-decoration: underline; /* Simple text hover effect */
}

/* Keep the options readable when opened */
#coach-selector option {
    background: #111;
    color: #fff;
    padding: 10px;
    direction: ltr; /* Reset text direction for the list itself */
}

/* LOCK IN OVERLAY */
#lock-in-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000; /* Pure Black */
    z-index: 10000;         /* Above everything */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;        /* Tells user to click */
}

.lock-msg {
    text-align: center;
    animation: pulse 2s infinite;
}

.lock-msg h1 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 10px;
    letter-spacing: -2px;
    color: #fff;
}

.lock-msg p {
    color: #4ade80; /* Matrix Green */
    font-size: 0.8rem;
    letter-spacing: 4px;
    text-transform: uppercase;
}

/* Optional Pulse Animation */
@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

/* Feedback when tapping a card to edit */
.card-left:active {
    opacity: 0.7;
    background-color: #2a2a2a; /* Slightly lighter */
    border-radius: 4px;
}

/* New Log Button in Saved Meals */
.log-meal-btn {
    background: #222;
    border: 1px solid #4ade80;
    color: #4ade80;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    margin-right: 10px;
    text-transform: uppercase;
}

.log-meal-btn:hover {
    background: #4ade80;
    color: #000;
}

/* Delete Row Button in Builder */
.row-delete-btn {
    background: #333;
    color: #666;
    border: none;
    width: 30px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.row-delete-btn:hover { color: #f87171; background: #222; }

/* Sleek "Add Ingredient" Button */
#add-row-btn {
    background: transparent;
    border: 1px dashed #333;
    color: #555;
    padding: 8px; /* Reduced from 15px */
    width: 100%;
    margin-bottom: 10px;
    font-size: 0.75rem; /* Smaller text */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#add-row-btn:hover {
    border-color: #4ade80; /* Green hover for feedback */
    color: #4ade80;
    background: rgba(74, 222, 128, 0.05);
}

/* Fix the Creator Panel spacing */
#meals-panel {
    padding-top: 20px;
}