:root {
    /* Pastel Palette (Vivid Mode) */
    --primary-color: #6366f1;
    /* Soft Indigo */
    --primary-hover: #818cf8;
    --danger-color: #f87171;
    /* Soft Rose */
    --danger-hover: #fca5a5;
    --success-color: #34d399;
    /* Soft Emerald */
    --success-hover: #6ee7b7;

    --bg-color: #f8fafc;
    /* Slate 50 */
    --card-bg: #ffffff;
    --text-color: #475569;
    /* Slate 600 - Softer than black */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --border-color: #e2e8f0;
    --input-bg: #ffffff;
    --header-bg: #f1f5f9;
}

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

body {
    font-family: 'Roboto Condensed', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

/* Enforce font on form elements */
button,
input,
optgroup,
select,
textarea {
    font-family: 'Roboto Condensed', sans-serif;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 1.5rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.logo .subtitle-link {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.2s;
}

.logo .subtitle-link:hover {
    color: var(--primary-color);
}

.logo .subtitle-link i {
    width: 14px;
    height: 14px;
}

.actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 0.8125rem;
}

.btn i {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-secondary {
    background-color: #fff;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--header-bg);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.table-container {
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed;
}

th {
    background-color: var(--header-bg);
    padding: 0.4rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
}

.root-domain-cell {
    font-weight: 500;
    color: var(--text-color);
    background: rgba(0, 0, 0, 0.02);
    border-right: 1px solid var(--border-color);
    font-size: 0.85rem;
    text-align: center;
}

td {
    padding: 0.25rem 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.deleted-section {
    margin-top: 3rem;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.deleted-section:hover {
    opacity: 1;
}

.deleted-section h2 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

#deleted-domains-table .data-input {
    color: var(--text-muted);
    cursor: not-allowed;
    background: transparent;
    border: none;
    box-shadow: none;
}

#deleted-domains-table tr {
    background-color: #f9fafb;
    /* Light gray for deleted */
}

#domains-body tr {
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

#domains-body tr:hover {
    box-shadow: inset 0 0 0 1000px rgba(255, 255, 255, 0.4);
    filter: brightness(1.01);
    z-index: 2;
}

#domains-body tr:focus-within {
    z-index: 10;
}

th:nth-child(1),
td:nth-child(1) {
    width: 12%;
}

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

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

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

th:nth-child(5),
td:nth-child(5) {
    width: 12%;
}

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

th:nth-child(7),
td:nth-child(7) {
    width: 6%;
}

th:nth-child(8),
td:nth-child(8) {
    width: 6%;
}

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

#domains-table .remove-row-btn {
    padding: 0.3rem;
    line-height: 0;
}

input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 0.35rem 0.5rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    color: var(--text-color);
    font-size: 0.8125rem;
    transition: all 0.2s;
}

/* Allow row colors to show through inputs in the table */
#domains-table .data-input {
    background-color: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.05);
}

#domains-table .data-input:focus {
    background-color: var(--input-bg);
    border-color: var(--primary-color);
}

::placeholder {
    color: #94a3b8;
    opacity: 0.7;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-box {
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    width: 100%;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    word-break: break-word;
    line-height: 1.2;
}

.btn-block {
    display: block;
    width: 100%;
    justify-content: center;
}

.login-box p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.alert-danger {
    background-color: #fee2e2;
    color: var(--danger-color);
    border: 1px solid #fecaca;
}

.table-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 300px;
}

.search-wrapper i {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    width: 16px;
    height: 16px;
}

#search-input {
    padding-left: 2.5rem;
}

.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    text-align: center;
}

.sortable:hover {
    background-color: #e2e8f0;
}

.sortable .sort-icon {
    display: none;
    vertical-align: middle;
    width: 14px;
    height: 14px;
    margin-left: 0.35rem;
    flex-shrink: 0;
}

.sortable .sort-icon.default {
    display: inline-block;
    opacity: 0.5;
}

.sortable.asc .sort-icon.default,
.sortable.desc .sort-icon.default {
    display: none;
}

.sortable.asc .sort-icon.asc {
    display: inline-block;
    color: var(--primary-color);
}

.sortable.desc .sort-icon.desc {
    display: inline-block;
    color: var(--primary-color);
}

.table-footer {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-start;
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(200%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background-color: var(--card-bg);
    width: 90%;
    max-width: 900px;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal.modal-sm {
    max-width: 450px;
}

.modal.modal-sm .modal-body {
    text-align: center;
    padding: 2.5rem 2rem;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.modal-body {
    padding: 2rem 1.5rem;
    overflow-y: auto;
    background-color: var(--card-bg);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-color);
}

.modal-footer {
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
}

.modal-body-console {
    padding: 0;
    overflow: hidden;
    background-color: #0f172a;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
    display: flex;
    flex-direction: column;
}

#log-container {
    padding: 1.5rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;
    font-size: 0.85rem;
    color: #f1f5f9;
    white-space: pre-wrap;
    margin: 0;
    line-height: 1.5;
    overflow-y: auto;
    max-height: 60vh;
}

#log-container::-webkit-scrollbar {
    width: 8px;
}

#log-container::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

/* Custom Dropdown Styles */
.dropdown-container {
    position: relative;
    width: 100%;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 100;
    margin-top: 0.25rem;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item:hover {
    background-color: var(--header-bg);
    color: var(--primary-color);
}

.dropdown-item.selected {
    background-color: var(--primary-color);
    color: white;
}

.dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }

    .logo {
        text-align: center;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn {
        justify-content: center;
        width: 100%;
        padding: 0.6rem;
    }

    .table-tools {
        flex-direction: column;
        gap: 0.75rem;
    }

    .search-wrapper {
        width: 100%;
    }

    /* Remove table container styling on mobile to avoid double-boxing */
    .table-container {
        background-color: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
        overflow: visible;
        /* Allow card shadows to show */
    }

    /* Card View for Table */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        background: var(--card-bg);
        overflow: hidden;
    }

    td {
        border: none;
        position: relative;
        padding-left: 45%;
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
        min-height: 40px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
    }

    td:last-child {
        border-bottom: none;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        justify-content: flex-end;
        background: #f8fafc;
    }

    td:before {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: 0.75rem;
        width: 40%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 700;
        font-size: 0.75rem;
        color: var(--text-muted);
        text-transform: uppercase;
        content: attr(data-label);
    }

    td:last-child:before {
        content: none;
    }

    .root-domain-cell {
        background-color: transparent !important;
        border-right: none;
        font-weight: 700;
        color: var(--primary-color);
        border-bottom: 2px solid var(--border-color) !important;
    }

    /* Input adjustments for mobile */
    input[type="text"],
    input[type="password"],
    input[type="number"] {
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    /* Width overrides for card view */
    td:nth-child(n) {
        width: 100%;
    }

    .remove-row-btn {
        width: 100%;
        justify-content: center;
        background-color: #fee2e2;
        color: var(--danger-color);
        border: 1px solid #fecaca;
    }

    .remove-row-btn:hover {
        background-color: var(--danger-color);
        color: white;
    }
}

/* Restart Notification */
.restart-needed-banner {
    background: linear-gradient(90deg, #ff4d4d, #f9cb28);
    /* Red to Yellow gradient */
    color: #fff;
    text-align: center;
    padding: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    display: none;
    /* Hidden by default */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.restart-needed-banner.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Adjust body padding so banner doesn't cover content when shown */
body.has-notification {
    padding-top: 60px;
}

@keyframes pulse-intense {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(220, 38, 38, 0);
        transform: scale(1.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
        transform: scale(1);
    }
}

.btn-restart-needed {
    animation: pulse-intense 1.5s infinite;
    background-color: #dc2626 !important;
    /* Red-600 */
    border-color: #dc2626 !important;
    position: relative;
    overflow: visible;
    /* Allow badge to spill out */
}

/* Badge for the button */
.btn-restart-needed::after {
    content: '!';
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #f59e0b;
    /* Amber warning */
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Unsaved Changes Notification */
.unsaved-changes-banner {
    background: linear-gradient(90deg, #3b82f6, #10b981);
    /* Blue to Green gradient */
    color: #fff;
    text-align: center;
    padding: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10000;
    /* Higher than restart banner so it shows on top while editing */
    display: none;
    /* Hidden by default */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.unsaved-changes-banner.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes pulse-blue {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
        transform: scale(1.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
        transform: scale(1);
    }
}

.btn-save-needed {
    animation: pulse-blue 1.5s infinite;
    position: relative;
    overflow: visible;
}

.btn-save-needed::after {
    content: '!';
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #3b82f6;
    /* Blue */
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Disabled Button Style */
button:disabled {
    background-color: #cbd5e1 !important;
    /* Slate-300 */
    border-color: #cbd5e1 !important;
    color: #64748b !important;
    /* Slate-500 */
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Unsaved Row Highlight */
.row-unsaved {
    background-color: #fff7ed !important;
    /* Orange-50 */
    box-shadow: inset 3px 0 0 0 #f97316 !important;
    /* Orange-500 border indicator */
    transition: background-color 0.3s;
}

/* Ensure unsaved input fields stand out slightly */
.row-unsaved .data-input {
    background-color: #fff;
    border-color: #fdba74;
    /* Orange-300 */
}