/* === PlateCalc - Mobile-First Gym Weight Calculator === */

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1e2d4f;
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --accent: #e63946;
    --accent-glow: rgba(230, 57, 70, 0.3);
    --accent-secondary: #457b9d;
    --accent-green: #2a9d8f;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 8px;

    --plate-red: #e63946;
    --plate-blue: #457b9d;
    --plate-yellow: #f4a261;
    --plate-green: #2a9d8f;
    --plate-white: #e0e0e0;
    --plate-black: #333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* === Header === */
.app-header {
    text-align: center;
    padding: 24px 0 16px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.logo-icon {
    filter: drop-shadow(0 2px 8px var(--accent-glow));
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent) 0%, #ff6b7a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* === Lift Selector === */
.lift-selector {
    display: flex;
    gap: 8px;
    padding: 8px 0 16px;
}

.lift-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    touch-action: manipulation;
}

.lift-btn .lift-icon { width: 36px; height: 36px; }
.lift-btn > * { pointer-events: none; }
.lift-btn:active { transform: scale(0.96); }

.lift-btn.active {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 20px var(--accent-glow), inset 0 0 20px rgba(230, 57, 70, 0.05);
}

/* === Weight Input === */
.weight-input-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.input-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-align: center;
}

.weight-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
}

.adj-btn {
    width: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    flex-shrink: 0;
}

.adj-btn:active {
    background: rgba(230, 57, 70, 0.15);
    border-color: var(--accent);
}

#targetWeight {
    flex: 1;
    text-align: center;
    font-size: 2.4rem;
    font-weight: 800;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    padding: 12px 8px;
    min-width: 0;
    -moz-appearance: textfield;
}

#targetWeight::-webkit-outer-spin-button,
#targetWeight::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#targetWeight:focus {
    border-color: var(--accent);
}

.unit-toggle {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.unit-btn {
    padding: 8px 28px;
    border: 2px solid var(--border);
    background: none;
    color: var(--text-secondary);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
    touch-action: manipulation;
}

.unit-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(230, 57, 70, 0.1);
}

/* === Bar Weight === */
.bar-weight-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.bar-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.bar-svg { width: 60px; height: 20px; flex-shrink: 0; }

.bar-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.bar-label strong { color: var(--text-primary); }

.bar-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.bar-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
    touch-action: manipulation;
}

.bar-btn.active {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
    background: rgba(69, 123, 157, 0.1);
}

/* === Results === */
.results-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.conversion-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 1rem;
    font-weight: 700;
}

.conv-lbs { color: var(--accent); }
.conv-kg { color: var(--accent-green); }
.arrow-icon { color: var(--text-secondary); flex-shrink: 0; }

.results-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.section-icon { color: var(--accent-secondary); flex-shrink: 0; }

/* === Visual Barbell === */
.plates-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 20px 0;
    min-height: 120px;
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.plate-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.65rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    position: relative;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    animation: slideIn 0.3s ease forwards;
}

.plate-visual .plate-weight-label { font-size: 0.7rem; line-height: 1; }
.plate-visual .plate-kg-label { font-size: 0.55rem; opacity: 0.8; margin-top: 2px; }

.bar-visual {
    height: 12px;
    background: linear-gradient(180deg, #ccc 0%, #888 100%);
    border-radius: 6px;
    min-width: 40px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.collar-visual {
    width: 10px;
    height: 28px;
    background: linear-gradient(180deg, #999 0%, #666 100%);
    border-radius: 2px;
    flex-shrink: 0;
}

/* Plate sizes */
.plate-45 { width: 22px; height: 100px; background: linear-gradient(135deg, #e63946 0%, #c62836 100%); }
.plate-35 { width: 20px; height: 90px; background: linear-gradient(135deg, #457b9d 0%, #356a8a 100%); }
.plate-25 { width: 18px; height: 80px; background: linear-gradient(135deg, #2a9d8f 0%, #1e8a7d 100%); }
.plate-10 { width: 16px; height: 65px; background: linear-gradient(135deg, #f4a261 0%, #e09050 100%); }
.plate-5  { width: 14px; height: 55px; background: linear-gradient(135deg, #e0e0e0 0%, #c0c0c0 100%); color: #333; text-shadow: none; }
.plate-2  { width: 12px; height: 45px; background: linear-gradient(135deg, #333 0%, #222 100%); }

.plate-20 { width: 22px; height: 100px; background: linear-gradient(135deg, #e63946 0%, #c62836 100%); }
.plate-15 { width: 20px; height: 90px; background: linear-gradient(135deg, #f4a261 0%, #e09050 100%); }
.plate-kg10 { width: 18px; height: 80px; background: linear-gradient(135deg, #2a9d8f 0%, #1e8a7d 100%); }
.plate-kg5 { width: 16px; height: 65px; background: linear-gradient(135deg, #e0e0e0 0%, #c0c0c0 100%); color: #333; text-shadow: none; }
.plate-kg2 { width: 14px; height: 50px; background: linear-gradient(135deg, #457b9d 0%, #356a8a 100%); }
.plate-kg1 { width: 12px; height: 40px; background: linear-gradient(135deg, #2a9d8f 0%, #1e8a7d 100%); }
.plate-kg0 { width: 10px; height: 35px; background: linear-gradient(135deg, #e0e0e0 0%, #c0c0c0 100%); color: #333; text-shadow: none; }

/* === Plates List === */
.plates-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.plate-count-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.plate-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.2);
}

.plate-count-info { display: flex; flex-direction: column; }
.plate-count-weight { font-weight: 700; font-size: 0.85rem; }
.plate-count-qty { font-size: 0.7rem; color: var(--text-secondary); }

/* === Error === */
.error-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: rgba(230, 57, 70, 0.1);
    border: 1px solid rgba(230, 57, 70, 0.3);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 0.85rem;
    margin-top: 12px;
}

/* === Presets === */
.presets-section { margin-bottom: 24px; }

.presets-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding-left: 4px;
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.preset-btn {
    padding: 12px 8px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    touch-action: manipulation;
}

.preset-btn:active {
    transform: scale(0.95);
    border-color: var(--accent);
}

.preset-btn .preset-kg {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

/* === Footer === */
.app-footer {
    text-align: center;
    padding: 16px 0 24px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.app-version {
    margin-top: 4px;
    font-size: 0.65rem;
    opacity: 0.5;
}

/* === Empty state === */
.empty-state { text-align: center; padding: 24px; color: var(--text-secondary); }
.empty-state svg { opacity: 0.3; margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; }

/* === Animations === */
@keyframes slideIn {
    from { transform: scaleX(0); opacity: 0; }
    to { transform: scaleX(1); opacity: 1; }
}

/* === Scrollbar === */
.plates-visual::-webkit-scrollbar { height: 4px; }
.plates-visual::-webkit-scrollbar-track { background: transparent; }
.plates-visual::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* === Media Queries === */
@media (max-width: 360px) {
    .app-container { padding: 0 10px; }
    .presets-grid { grid-template-columns: repeat(3, 1fr); }
    #targetWeight { font-size: 1.8rem; }
}

@media (min-width: 480px) {
    .app-container { padding: 0 24px; }
}

@media (display-mode: standalone) {
    .app-header { padding-top: 48px; }
}
