/* ========= Page base ========= */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* page does not scroll; tables do */
}

body {
    background-color: #121212;
    box-sizing: border-box;
    color: #e0e0e0;
    font-family: sans-serif;
    margin: 0;
    padding: 10px;
    font-size: 0.9rem;
}

h1, h2, h3 { color: #ffffff; }

h2 {
    font-size: 1.2rem;
    margin-top: 0;
    margin-bottom: 10px;
}

/* ========= Layout ========= */
.container {
    height: calc(100vh - 20px); /* body padding */
    display: flex;
    flex-direction: column;
    min-height: 0; /* critical for nested scroll */
}

/* Header + tabs block */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #121212;
    padding-bottom: 8px;
}

/* The remaining area under tabs */
.tab-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden; /* prevent double scrollbar */
    padding-top: 10px;
}

/* Tabs show/hide */
.tab-content { display: none; }
.tab-content.active {
    display: block;
    height: 100%;
}

/* Make card fill the tab so table can be the scroller */
.tab-content .card {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ========= Cards ========= */
.card {
    background-color: #1e1e1e;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* ========= Inputs / Buttons ========= */
input[type="text"], input[type="password"], select {
    background-color: #2c2c2c;
    border: 1px solid #444;
    color: #fff;
    padding: 6px;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 5px;
}

button {
    background-color: #bed739;
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    background-color: #bed739cc;
    scale: 1.1;
}

button.delete {
    background-color: #cf667987;
}

button.delete:hover {
    background-color: #ff6666aa;
    scale: 1.1;
}

button.sub-button {
    background-color: #bed73961;
    color: black;
    padding: 5px 10px;
    font-size: 0.8em;
}

button.sub-button:hover {
    background-color: #bed739;
    color: black;
    padding: 5px 10px;
    font-size: 0.8em;
    scale: 1.1;
}

/* ========= Forms ========= */
.form-group { margin-bottom: 10px; }

label {
    display: block;
    margin-bottom: 4px;
}

/* ========= Tabs ========= */
.tabs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.tab-btn {
    padding: 8px 14px;
    border: 1px solid #444;
    background: #222;
    color: #ccc;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
}

.tab-btn.active {
    background: #333;
    color: #fff;
    border-bottom-color: transparent;
}

/* ========= Table ========= */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 5px;
    cursor: default;
}

th, td {
    text-align: left;
    padding: 6px;
    border-bottom: 1px solid #333;
}

th {
    background-color: #121212;
}

/* Stripe look you had */
tr:nth-child(even) {
    background: linear-gradient(to right, #aaaaaa12, transparent);
}
tr:nth-child(odd) {
    background: linear-gradient(to left, #aaaaaa12, transparent);
}
tr:hover {
    background: #cccccc22;
}

/* ========= Table-only scrolling =========
   This is the only scrollbar on the page
*/
.table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    border: 1px solid #333;
    border-radius: 6px;
    margin: 1em;
    /* prevents last row looking clipped */
    padding-bottom: 6px;
    box-sizing: border-box;
}

/* keep table headers visible while scrolling */
.table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #121212;
}

/* ========= Pills Styles ========= */
.pill-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.pill {
    background-color: #333;
    color: white;
    padding: 2px 8px;
    border: 1px solid #666;
    border-radius: 12px;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pill.advanced {
    background-color: #b0002057;
    border: 1px solid #cf6679a8;
}

.pill .remove {
    cursor: pointer;
    font-weight: bold;
    color: #ff80ab;
}

.pill .remove:hover {
    color: #ff4081;
}

.add-pill-btn {
    background-color: #bed73959;
    color: black;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    padding: 0;
}

/* DB permission rows in user view */
.db-permissions-row {
    margin-bottom: 6px;
    border-bottom: 1px solid #444;
    padding-bottom: 6px;
}
.db-permissions-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.db-name-label {
    font-weight: bold;
    color: #69d10d91;
    margin-bottom: 4px;
    display: block;
    font-size: 0.9em;
}
.db-name-label.non-existent { color: #cf6679; }

.remove-all-btn {
    background: none;
    border: none;
    color: #cf6679;
    cursor: pointer;
    font-size: 1.1em;
    padding: 0 4px;
}

/* ========= Modal ========= */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1e1e1e;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 350px;
    border-radius: 8px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.checkbox-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.checkbox-item input {
    width: auto;
    margin-right: 10px;
}

.checkbox-item label {
    margin-bottom: 0;
    font-weight: bold;
}

.perm-description {
    font-size: 0.8em;
    color: #aaa;
    margin-left: 24px;
    margin-top: -4px;
}

/* ========= Toasts ========= */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 260px;
    padding: 12px 16px;
    border-radius: 6px;
    color: white;
    font-size: 0.9em;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    animation: slideIn 0.3s ease-out;
}

.toast.success { background: #2e7d32; }
.toast.error   { background: #c62828; }
.toast.info    { background: #1565c0; }

@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ===== Scrollbar styling (WebKit / Chromium) ===== */
.table-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-scroll::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 10px;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(
            180deg,
            #bed739,
            #9fb92f
    );
    border-radius: 10px;
    border: 2px solid #1a1a1a; /* creates padding illusion */
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(
            180deg,
            #d6f04a,
            #b5cf36
    );
}

/* Corner where horizontal + vertical meet */
.table-scroll::-webkit-scrollbar-corner {
    background: #1a1a1a;
}

/* ===== Firefox scrollbar styling ===== */
.table-scroll {
    scrollbar-width: thin;
    scrollbar-color: #bed739 #1a1a1a;
}
