/* ======================================================
   SETTINGS PANEL LAYOUT & CORE FIELDS
====================================================== */

.label {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg);
    align-self: flex-start;
}

.field-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.subfield-list {
    width: 100%;
}

#settingsForm .subfield {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin-top: 0.15em;
}

.field-hint {
    margin-top: 0.25em;
    font-size: 0.95em;
    color: var(--fg-secondary);
}

.field-hint-warning-text {
    color: var(--error);
}

/* ======================================================
   BUTTONS & ACTIONS
====================================================== */
.field > button.add-control-btn {
    margin-top: 0.75rem;
    align-self: start;
    grid-column: 1;
    grid-row: 2;
    position: relative;
    left: 0;
}

.setting-entry-actions {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    margin-left: auto;
    align-self: center;
}

.remove-directory {
    min-width: 0;
    min-height: 20px;
    padding: 0.25rem 0.5rem;
}

/* ======================================================
   DRAG & DROP/ENTRY HOVER
====================================================== */
.draggable.drag-over {
    border: 2px dashed var(--primary-bg);
    transform: translateY(5px);
}

/* ======================================================
   ENTRY CARDS & LAYOUTS
====================================================== */
.card.setting-entry {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

/* ======================================================
   TABLES (UPGRADINATORR)
====================================================== */
.upgradinatorr-table {
    width: 100%;
    max-width: 100vw;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 0.5rem;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 6px var(--shadow);
    overflow: hidden;
    table-layout: auto;
    font-size: 1rem;
}

.upgradinatorr-table th,
.upgradinatorr-table td {
    padding: 0.5rem 1.2rem;
    border-bottom: 1px solid var(--shadow);
    vertical-align: middle;
}

.upgradinatorr-table th {
    background: var(--table-header);
    font-weight: 700;
    color: var(--fg);
    text-align: center;
    font-size: 1.08rem;
    letter-spacing: 0.01em;
}

.upgradinatorr-table td {
    background: var(--card-bg);
    font-size: 1rem;
}

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

.upgradinatorr-table td:last-child {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.upgradinatorr-table tr:hover td {
    background: var(--card-hover-bg);
    transition: background 0.15s;
}

.upgradinatorr-table {
    border-radius: 12px;
    overflow: hidden;
}

.upgradinatorr-table thead tr:first-child th:first-child {
    border-top-left-radius: 12px;
}

.upgradinatorr-table thead tr:first-child th:last-child {
    border-top-right-radius: 12px;
}

.upgradinatorr-table tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

.upgradinatorr-table tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

/* ======================================================
   PLEX INSTANCE CARD & LIBRARIES
====================================================== */
.card.plex-instance-card {
    width: 100% !important;
    flex-grow: 1;
    align-self: stretch;
    box-sizing: border-box;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    margin-bottom: 2rem;
}

.plex-instance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.plex-instance-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--fg);
}

.plex-libraries {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    overflow: hidden;
    opacity: 0;
    margin-top: 1rem;
    transition: max-height 0.4s ease, opacity 0.4s ease;
}

.plex-libraries.open {
    opacity: 1;
}

/* ======================================================
   BORDER COLOR PICKER
====================================================== */
#border-colors-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
    min-height: 3rem;
}

#border-colors-container .subfield {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

#border-colors-container .subfield input[type='color'] {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: none;
}

/* ======================================================
   HOLIDAY COLOR SWATCHES/CARDS
====================================================== */
.holiday-swatch {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 2px;
    margin: 0 0.25rem;
    vertical-align: middle;
    border: 1px solid var(--fg);
}

.holiday-card {
    background: var(--card-bg);
    padding: var(--card-padding);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 1rem;
}

.holiday-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.holiday-app {
    font-weight: 600;
    color: var(--fg);
}

.holiday-labels {
    font-style: italic;
    color: var(--fg-secondary, #aaa);
    margin-left: 1rem;
}

/* ======================================================
   LABELARR MAPPING CARDS
====================================================== */
.labelarr-mapping-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.7rem;
    padding: 1.15rem 1.7rem;
    background: var(--card-bg);
    border-radius: 8px;
    border: var(--card-border);
    margin-bottom: 1rem;
    box-shadow: 0 1px 6px var(--shadow);
}

.labelarr-mapping-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 180px;
    gap: 0.45em;
}

.mapping-app {
    font-size: 1.13em;
    color: var(--fg);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.mapping-instance {
    font-size: 1em;
    color: var(--mapping-instance-color);
}

.mapping-instance span {
    color: var(--fg);
    font-weight: 500;
}

.mapping-labels {
    margin-top: 0.1em;
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
}

.labelarr-label {
    background: var(--labelarr-label-bg);
    color: var(--labelarr-label-color);
    font-weight: 500;
    font-size: 0.99em;
    border-radius: 5px;
    padding: 0.16em 0.75em;
    letter-spacing: 0.01em;
}

.labelarr-label-empty {
    color: var(--labelarr-label-empty-color);
}

.labelarr-mapping-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}

.labelarr-arrow {
    font-size: 1.5em;
    color: var(--labelarr-arrow-color);
}

.labelarr-mapping-right {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.7em;
    min-width: 130px;
    max-width: 380px;
}

.labelarr-plex-target {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4em;
    margin-bottom: 0.15em;
}

.labelarr-plex-instance {
    color: var(--labelarr-plex-instance-color);
    font-weight: 600;
    font-size: 1.06em;
}

.labelarr-library {
    background: var(--labelarr-library-bg);
    color: var(--labelarr-library-color);
    border-radius: 4px;
    padding: 0.1em 0.8em;
    font-size: 0.99em;
    margin-left: 0.32em;
}

.labelarr-mapping-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.75em;
    min-width: 120px;
}

.labelarr-mapping-left,
.labelarr-mapping-center,
.labelarr-mapping-right,
.labelarr-mapping-actions {
    min-width: 0;
}

/* ======================================================
   LIBRARY PILL COMPONENTS & ACTIONS
====================================================== */
.library-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.library-actions > div {
    display: flex;
    gap: 0.5rem;
}

.library-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.7em;
    padding: 0.48em 1.1em;
    background: var(--card-bg);
    border: var(--pill-border);
    border-radius: var(--pill-radius);
    font-size: 1rem;
    font-weight: 500;
    color: var(--fg);
    cursor: pointer;
    margin-bottom: 0.45rem;
    transition: border-color 0.18s, background 0.2s, box-shadow 0.18s;
    user-select: none;
    min-width: 0;
    min-height: 2.2em;
}

.library-pill input[type='checkbox'] {
    margin-right: 0.7em;
    accent-color: var(--primary);
    width: 1.15em;
    height: 1.15em;
}

.library-pill:hover,
.library-pill:focus-within {
    border-color: var(--focus);
    background: var(--pill-hover-bg);
    box-shadow: var(--pill-hover-shadow);
}

.library-pill:active {
    background: var(--pill-active-bg);
}

.library-pill input[type='checkbox']:checked + span,
.library-pill input[type='checkbox']:checked {
    font-weight: 600;
}

.library-pill input[type='checkbox']:focus {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.library-pill input[type='checkbox']:checked ~ * {
    color: var(--focus);
}

/* Animate settings cards (top-level .card, and GDrive sync .card.setting-entry) */
#settingsForm .card,
#settingsForm .card.setting-entry {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
    transition: opacity 0.28s cubic-bezier(0.44, 1.13, 0.73, 0.98),
        transform 0.28s cubic-bezier(0.44, 1.13, 0.73, 0.98);
}

#settingsForm .card.show-card,
#settingsForm .card.setting-entry.show-card {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Animate all fields inside cards */
#settingsForm .field {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    transition: opacity 0.28s cubic-bezier(0.44, 1.13, 0.73, 0.98),
        transform 0.28s cubic-bezier(0.44, 1.13, 0.73, 0.98);
}

#settingsForm .field.show-field {
    opacity: 1;
    transform: translateY(0) scale(1);
}
