:root {
    --primary: #000000;
    --primary-dark: #262626;
    --bg: #ffffff;
    --card-bg: #f8f9fa;
    --text: #171717;
    --text-muted: #525252;
    --border: #e5e5e5;
    --success: #16a34a;
    /* Slightly darker green for light mode contrast */
    --accent-gold: #d4af37;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    line-height: 1.5;
}

.container {
    width: 100%;
    max-width: 1100px;
    /* Increased from 800px */
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #000000, #d4af37);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
}

.card {
    background-color: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    margin-bottom: 2rem;
    max-width: 600px;
    /* Keep input form focused/narrower */
    margin-left: auto;
    margin-right: auto;
}

.input-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
}

select,
input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background-color: #ffffff;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

select:focus,
input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

/* Generic Button Reset */
button {
    width: 100%;
    padding: 1rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

button:hover {
    background-color: var(--primary-dark);
}

/* Calculate Button Specifics */
#calculate-btn {
    background: linear-gradient(135deg, #d4af37, #b45309);
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 6px -1px rgba(212, 175, 55, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(212, 175, 55, 0.5);
    background: linear-gradient(135deg, #e5c155, #d97706);
}

#calculate-btn:active {
    transform: scale(0.98);
}

/* Click Animation Class for JS */
.button-click {
    animation: buttonPulse 0.3s ease-out;
}

@keyframes buttonPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.95);
        background-color: var(--primary-dark);
    }

    100% {
        transform: scale(1);
    }
}

/* Table Styles - Fixed Nesting Issue & Layout */
.result-container {
    margin-top: 2rem;
    overflow-x: auto;
    border-radius: 12px;
    border-radius: 12px;
    background: var(--card-bg);
    /* Light border for definition */
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    /* Increased min-width to force scrolling if needed */
}

th,
td {
    padding: 1.5rem;
    /* Increased padding */
    text-align: right;
    /* Default align right for numbers */
    color: var(--text-muted);
    vertical-align: middle;
}

/* Column Specifics */
th:nth-child(1),
td:nth-child(1) {
    text-align: left;
    /* Align Model Name Left */
    width: 40%;
    /* Give Model the most space */
}

th:nth-child(2),
td:nth-child(2) {
    width: 15%;
}

th:nth-child(3),
td:nth-child(3) {
    width: 15%;
}

th:nth-child(4),
td:nth-child(4) {
    width: 20%;
}

th:nth-child(5),
td:nth-child(5) {
    width: 10%;
    text-align: center;
}

th {
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1.5px;
    white-space: nowrap;
    /* Prevent headers binding */
}

td {
    border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
    /* Slightly larger text */
    color: var(--text);
}

tr:last-child td {
    border-bottom: none;
}

.value-cell {
    font-weight: 800;
    color: var(--success);
    font-size: 1.4rem;
    /* Make value score pop */
}

/* Specific Delete Button Overrides - Added !important to be safe against generic button */
button.delete-btn {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    justify-content: center;
    align-items: center;
    background: rgba(255, 71, 87, 0.1) !important;
    border-radius: 8px;
    color: #ff4757;
    font-size: 1.2rem;
    line-height: 1;
    margin: 0 auto;
    opacity: 0.8;
}

button.delete-btn:hover {
    background: rgba(255, 71, 87, 0.2) !important;
    opacity: 1;
    transform: scale(1.1);
}

button.delete-btn:active {
    transform: scale(0.9);
}

.hidden {
    display: none;
}

/* Animations */
@keyframes highlightAndSlide {
    0% {
        background: rgba(99, 102, 241, 0.2);
        opacity: 0;
        transform: translateY(-10px);
    }

    30% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        background: transparent;
    }
}

.new-row {
    animation: highlightAndSlide 1s ease-out forwards;
}

/* Max iOS Status Styling */
.max-ios-latest {
    box-shadow: inset 4px 0 0 var(--success);
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
}

.max-ios-outdated {
    box-shadow: inset 4px 0 0 #ef4444;
    /* Red-500 */
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.05) 0%, transparent 100%);
}

.max-ios-outdated td {
    color: var(--text-muted);
    /* Muted text for old devices */
}

footer {
    text-align: center;
    margin-top: 4rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Champion/Winner Row Styling */
.champion-row td {
    color: var(--text);
    background: rgba(212, 175, 55, 0.1);
    /* Gold tint */
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.champion-row .model-name {
    font-weight: 700;
    color: #b45309;
    /* Darker Gold/Amber for readability on light bg */
}

.champion-row .value-cell {
    color: #b45309;
    text-shadow: none;
}

.trophy-icon {
    font-size: 1.2rem;
    margin-left: 0.5rem;
}

/* Secondary Actions */
.secondary-btn {
    background-color: var(--card-bg);
    /* Darker default */
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 0.75rem;
    margin-top: 1rem;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
}

.secondary-btn:hover {
    background-color: #334155;
    color: white;
    border-color: #475569;
}

/* Ensure Clear All is hidden properly */
.hidden {
    display: none !important;
}

/* Chip Badge */
.chip-badge {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.champion-row .chip-badge {
    color: #b45309;
    background: rgba(212, 175, 55, 0.2);
}

.price-edit-input {
    width: 100px;
    padding: 0.25rem;
    font-size: 1rem;
    font-size: 1rem;
    background: white;
    color: var(--text);
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    text-align: center;
}

/* Remove spinners for Chrome, Safari, Edge, Opera */
input.price-edit-input::-webkit-outer-spin-button,
input.price-edit-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Remove spinners for Firefox */
input.price-edit-input[type=number] {
    -moz-appearance: textfield;
}