:root {
    --primary: #a2e1c3;
    --secondary: #f26f6f;
    --accent: #ffd85f;
    --yellow-light: #fce79d;
    --blue: #91e6fb;
    --blue-dark: #0e7189;
    --light: #fbfbfb;
    --bg: #fff;
    --text: #333;
    --card-bg: #f7fafc;
    --table-bg: #fff;
    --table-hover: #f7fafc;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-light: rgba(0, 0, 0, 0.05);
    --font: "Montserrat Alternates", sans-serif;
}

[data-theme="dark"] {
    --bg: #1a1a1a;
    --text: #e0e0e0;
    --text-dark: #3a3a3a;
    --card-bg: #2a2a2a;
    --table-bg: #2a2a2a;
    --table-hover: #3a3a3a;
    --border: #444;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-light: rgba(0, 0, 0, 0.2);
}

body {
    font-family: var(--font);
    background: var(--yellow-light);
    color: var(--text);
    margin: 0;
    padding: 1.25rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background 0.3s ease, color 0.3s ease;
    position: relative;
    overflow-x: clip;
    overflow-y: auto;
}

#sun-moon {
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: yellow;
    z-index: -1;
    transition: left 0.5s ease, top 0.5s ease, background 0.5s ease, filter 0.5s ease;
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.5);
}

.container {
    max-width: 50rem;
    width: 100%;
    background: #1a1a1a91;
    border-radius: 1.25rem;
    box-shadow: 0 1.25rem 2.5rem var(--shadow);
    padding: 1.875rem;
    margin-top: 1.25rem;
}

h1 {
    text-align: center;
    color: var(--text);
    font-weight: 700;
    margin-bottom: 1.875rem;
    font-size: 2.5em;
}

h2 {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 1.25rem;
}

h3 {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.9375rem;
}

.controls {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.875rem;
}

#current-location, #add-location, #settings, #share {
    flex: 1;
    min-width: 15.625rem;
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: 0.625rem;
    box-shadow: 0 0.25rem 0.375rem var(--shadow-light);
}

#current-location {
    background-color: var(--accent);
    position: relative;
    overflow: clip;

    label {
        color: var(--text-dark)
    }

    &:before {
        content: '';
        position: absolute;
        bottom: -0.5rem;
        right: -1rem;
        width: 5rem;
        height: 5rem;
        background-image: url('img/home.svg');
        background-repeat: no-repeat;
        background-size: 100%;
        background-position: center;
    }
}

#add-location {
    background-color: var(--blue);
    position: relative;
    overflow: clip;

    label {
        color: var(--text-dark)
    }

    button {
        background-color: var(--blue-dark);
        color: var(--light);
    }

    &:before {
        content: '';
        position: absolute;
        bottom: -2rem;
        right: -2rem;
        width: 7rem;
        height: 7rem;
        background-image: url('img/plus.svg');
        background-repeat: no-repeat;
        background-size: 100%;
        background-position: center;
    }
}

#settings {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;

    @media (min-width: 47.9375rem) {
        flex-direction: row;
    }
}

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

input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 0.125rem solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    background: var(--bg);
    color: var(--text);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 0.1875rem rgba(242, 111, 111, 0.1);
}

button {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: black;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 0.625rem;
    font-family: var(--font);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 700;
}

button:hover {
    transform: translateY(-0.125rem);
    box-shadow: 0 0.5rem 0.9375rem rgba(242, 111, 111, 0.3);
}

table button {
    margin-top: 0;
}

#settings h3 {
    margin: 0;
}

#settings label {
    display: flex;
    font-weight: 400;
}

#settings input[type="radio"] {
    margin-right: 0.3125rem;
}

.setting-group {
    margin-bottom: 0;
}

.setting-group label {
    display: inline;
    margin-right: 0.9375rem;
    margin-bottom: 0;
    font-weight: 400;
}

.setting-group label:first-child {
    display: block;
    margin-bottom: 0.3125rem;
    font-weight: 600;
}

#times {
    margin-top: 1.875rem;
}

#share h3 {
    margin-top: 0;
}

#share button {
    padding: 0.625rem;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0.3125rem;
}

#times-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--table-bg);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 0.25rem 0.375rem var(--shadow-light);
    margin-bottom: 1.25rem;
}

#times-table th, #times-table td {
    padding: 0.9375rem;
    text-align: left;
    border-bottom: 0.0625rem solid var(--border);
}

#times-table th {
    background: var(--card-bg);
    font-weight: 700;
    color: var(--text);
}

#times-table tbody tr:hover {
    background: var(--table-hover);
    color: var(--text);
}

#times-table td:last-child {
    text-align: right;
    vertical-align: middle;
    padding-right: 1.25rem;
}

#times-table button {
    vertical-align: middle;
    font-size: 1rem;
    padding: 0.375rem 0.5rem;
    background: none;
    border: none;
    color: red;
    cursor: pointer;
}

.time-format {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.drag-icon {
    vertical-align: middle;
}

small {
    font-size: 0.65em;
    color: var(--text);
    background: var(--card-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 0.625rem;
    margin-left: 0.3125rem;
    display: inline-block;
}

#times-table tr[draggable="true"] {
    cursor: move;
}

#times-table tr[draggable="true"]:hover {
    background: var(--table-hover);
}

.drag-icon {
    cursor: move;
    font-size: 1.2em;
    margin-left: 0.625rem;
    color: #666;
}

/* Responsive Design */
@media (max-width: 48rem) {
    body {
        padding: 0.625rem;
    }

    .container {
        padding: 1.25rem;
        margin-top: 0.625rem;
    }

    h1 {
        font-size: 2em;
        margin-bottom: 1.25rem;
    }

    .controls {
        flex-direction: column;
        gap: 0.9375rem;
    }

    #current-location, #add-location, #settings {
        min-width: auto;
    }

    #times-table {
        font-size: 0.875rem;
    }

    #times-table th, #times-table td {
        padding: 0.625rem;
    }

    #times-table td:last-child {
        padding-right: 0.625rem;
    }

    .drag-icon {
        font-size: 1em;
        margin-left: 0.3125rem;
    }
}

@media (max-width: 30rem) {
    .container {
        padding: 0.9375rem;
    }

    h1 {
        font-size: 1.5em;
    }

    #times-table {
        overflow-x: auto;
        display: block;
        white-space: nowrap;
    }

    #times-table th, #times-table td {
        padding: 0.5rem;
        min-width: 5rem;
    }
}


.copy {
    text-align: center;
    font-size: 0.75rem;
    margin-top: 2rem;
    margin-bottom: 0;

    a {
        text-decoration: none;
        color: var(--text);

        &:hover {
            text-decoration: underline;
        }
    }
}

/* Modern Switches */
input[type="radio"], input[type="checkbox"] {
    display: none;
}

.setting-group input[type="radio"] + label {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.3s, color 0.3s;
    margin-right: 0;
}

.setting-group input[type="radio"]:checked + label {
    background: var(--primary);
    color: black;
}

label[for="dark-mode"] {
    position: relative;
    display: inline-block;
    padding-left: 3.5rem;
    cursor: pointer;
    line-height: 1.5rem;
}

label[for="dark-mode"]::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3rem;
    height: 1.5rem;
    background: var(--text);
    border-radius: 1rem;
    transition: background 0.3s;
}

label[for="dark-mode"]::after {
    content: '';
    position: absolute;
    left: 0.125rem;
    top: 0.125rem;
    width: 1.25rem;
    height: 1.25rem;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

#dark-mode:checked + label[for="dark-mode"]::before {
    background: var(--primary);
}

#dark-mode:checked + label[for="dark-mode"]::after {
    transform: translateX(1.5rem);
}