@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');

/* Utility */
.hidden {
    display: none !important;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(to bottom right, #808080, #40e0d0, #ffa500);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    height: 100vh; /* Fixed height */
    overflow: hidden; /* Prevent body scroll */
    padding: 0; /* No padding for full screen */
    background-attachment: fixed;
}

.container {
    width: 100%;
    /* Default for mobile (max-width will override for smaller screens) */
    max-width: calc(100% - 2rem); /* Keep a small gap for mobile */
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px); /* For Safari */
    border-radius: 20px; /* Default for mobile */
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3); /* Default for mobile */
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); /* Default for mobile */
    height: 100%; /* Ensure container takes full available height from body */
}

/* --- Table Selection Modal (Replaces Sidebar) --- */
#table-selection-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Darker background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2500;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#table-selection-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#table-selection-modal-content {
    background: rgba(0, 0, 0, 0.4); /* Slightly transparent dark */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 500px;
    height: 80vh; /* Tall window */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(1);
    transition: transform 0.3s ease-in-out;
}

#table-selection-modal-overlay.hidden #table-selection-modal-content {
    transform: scale(0.95);
}

.modal-header-row {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.2);
}

.modal-header-row h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #40e0d0;
    text-align: left;
}

.close-btn-x {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.3s;
}
.close-btn-x:hover { color: #fff; }

.selection-search-container {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#table-selection-search-input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 1rem;
}

.selection-list-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.modal-footer-row {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.2);
}

.full-width-btn {
    width: 100%;
    padding: 1rem;
    background: #40e0d0;
    border: none;
    border-radius: 10px;
    color: #2a2a2a;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}
.full-width-btn:hover { 
    background: #2bc4b4; 
    transform: translateY(-2px);
}

/* List Items Styling */
.folder-item {
    margin-bottom: 0.8rem;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    overflow: hidden;
}

.folder-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 1rem;
    transition: background 0.2s;
    color: rgba(255,255,255,0.9);
    font-weight: 600;
}
.folder-header:hover {
    background: rgba(255,255,255,0.08);
}
.folder-icon { margin-right: 10px; font-size: 0.9rem; transition: transform 0.2s; }
.folder-item.open .folder-icon { transform: rotate(90deg); }
.folder-name { flex-grow: 1; }
.folder-count { font-size: 0.8rem; opacity: 0.6; background: rgba(0,0,0,0.3); padding: 2px 8px; border-radius: 10px; }

.folder-content {
    display: none; 
    background: rgba(0,0,0,0.1);
}
.folder-item.open .folder-content { display: block; }

.table-item {
    padding: 0.8rem 1rem 0.8rem 2.5rem; /* Indent */
    cursor: pointer;
    border-top: 1px solid rgba(255,255,255,0.03);
    transition: background 0.2s;
    
    /* New Layout: Stacked */
    display: flex;
    flex-direction: column; 
    align-items: flex-start;
    gap: 2px;
}

.table-item:first-child { border-top: none; }

.table-item:hover {
    background: rgba(255,255,255,0.08);
}

.table-item.active {
    background: rgba(64, 224, 208, 0.15); 
    border-left: 4px solid #40e0d0;
    padding-left: calc(2.5rem - 4px); /* Adjust padding for border */
}

.table-name-text {
    font-size: 1rem;
    color: #fff;
    font-weight: 500;
}
.table-item.active .table-name-text {
    color: #40e0d0;
    font-weight: 600;
}

.table-meta {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    font-style: italic;
}

/* Header (now inside main, so it scrolls) */
header {
    text-align: left; /* Align text left within header */
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-main-controls {
    display: flex;
    justify-content: space-between; /* Pushes children to ends */
    align-items: center; /* Aligns items vertically center */
    margin-bottom: 0.5rem; /* Space below this row */
}

.header-left-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-grow: 1;
    min-width: 0; /* Allow shrinking */
}

#header-table-name {
    margin: 0;
    font-size: 1.5rem; /* Slightly smaller than h1 */
    white-space: normal;
    word-break: break-word;
    line-height: 1.2; /* Better readability for wrapped text */
}

#sidebar-toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    border-radius: 5px;
}
#sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.1);
}

.header-right-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0; /* Prevent shrinking */
}

.user-menu-container {
    position: relative; /* Needed for absolute positioning of child elements (dropdown) */
    /* Removed flexbox centering for button and dot */
    /* display: flex; */
    /* flex-direction: column; */
    /* align-items: center; */
}

#user-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s;
    display: block; /* Ensure it takes full width for margin auto to work */
    margin-left: auto; /* Center the button */
    margin-right: auto;
}

.user-icon-img {
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    filter: brightness(0) invert(1) drop-shadow(0 0 2px rgba(0,0,0,0.8)) !important;
    display: block;
}

/* Connection Status */
#connection-status {
    width: 25px; /* Size of the dot */
    height: 25px; /* Size of the dot */
    border-radius: 50%; /* Make it round */
    transition: all 0.3s ease-in-out;
    flex-shrink: 0; /* Prevent squashing */
    border: 2px solid rgba(255, 255, 255, 0.2); /* Border for visibility */
    cursor: default; /* Not clickable */
}

#connection-status.connected {
    background-color: #2ecc71; /* Green */
    box-shadow: 0 0 5px #2ecc71;
}

#connection-status.disconnected {
    background-color: #e74c3c; /* Red */
    box-shadow: 0 0 5px #e74c3c;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* Shift Dropdown down to make room for the dot (no dot now) */
#user-dropdown {
    position: absolute;
    top: 100%; /* Position directly below the button */
    right: 0;
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    width: 220px; /* Slightly wider */
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    z-index: 2000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dropdown-header {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.dropdown-header span {
    font-weight: 600;
    color: #40e0d0;
    font-size: 1.1rem;
}

.dropdown-header small {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
}

.dropdown-items {
    list-style: none;
    padding: 0.5rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.dropdown-items li {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05); /* Subtle button background */
    border: 1px solid transparent;
}

.dropdown-items li:hover {
    background: rgba(64, 224, 208, 0.15);
    color: #40e0d0;
    border-color: rgba(64, 224, 208, 0.3);
    transform: translateY(-1px);
}

.dropdown-items li:active {
    transform: translateY(0);
}

.dropdown-items li#logout-link {
    margin-top: 0.5rem;
    background: rgba(231, 76, 60, 0.1);
    color: #ff6b6b;
}

.dropdown-items li#logout-link:hover {
    background: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.4);
    color: #ff4f4f;
}

.status-dot {
    display: none;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem; /* Reduced space */
}

/* Media Query for Desktop (larger screens) */
@media (min-width: 769px) {
    .container {
        max-width: none; /* No max-width on desktop */
        border-radius: 0; /* No rounded corners at edges */
        border: none; /* Remove border */
        box-shadow: none; /* Remove shadow */
    }

    body {
        padding: 0; /* Ensure no padding on desktop for full screen */
    }
}


/* Login View Specifics */
#login-view header {
    text-align: center;
    border-bottom: none;
}

/* Login Form Styling */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 400px;
    margin: 4rem auto; /* More space from top */
    padding: 2.5rem;
    background: rgba(0, 0, 0, 0.2); /* Darker background */
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.login-form input {
    width: 100%;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.login-form input:focus {
    outline: none;
    border-color: #40e0d0;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(64, 224, 208, 0.1);
}

.login-form input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#login-btn {
    width: 100%;
    padding: 1rem;
    margin-top: 0.5rem;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #40e0d0 0%, #2bc4b4 100%);
    color: #1a1a1a;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s;
    box-shadow: 0 4px 15px rgba(64, 224, 208, 0.3);
}

#login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(64, 224, 208, 0.4);
}

#login-btn:active {
    transform: translateY(1px);
}

#login-error {
    text-align: center;
    background: rgba(231, 76, 60, 0.2);
    color: #ff6b6b;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(231, 76, 60, 0.3);
    font-size: 0.9rem;
}


.view {
    display: none;
}

.view.active-view {
    display: flex; /* Make app-view a flex container */
    flex-direction: column; /* Stack children vertically */
    height: 100%; /* Take available height from parent (body - padding) */
    max-height: 100%;
}

h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* When inside header, reset margin */
header h2 {
    text-align: left;
    margin-bottom: 0;
}

.view.active-view main {
    flex-grow: 1; /* Allow main to take up remaining vertical space */
    overflow-y: auto; /* Enable vertical scrolling */
    padding-bottom: 1rem; /* Add some padding at the bottom for better look */
    min-height: 0; /* Critical for flex child scrolling */
    /* Hide vertical scrollbar for Webkit browsers */
    &::-webkit-scrollbar {
        width: 0px;  /* For vertical */
        height: 0px; /* For horizontal (if any) */
    }
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
}

.table-container {
    margin-bottom: 1.5rem;
    overflow-x: auto; /* Enable horizontal scrolling */
    overflow-y: hidden; /* Hide vertical scrollbar for table container */
    scrollbar-width: none; /* Firefox (horizontal) */
    -ms-overflow-style: none;  /* IE 10+ (horizontal) */

    /* Hide vertical scrollbar for Webkit browsers */
    &::-webkit-scrollbar:vertical {
        display: none;
    }
    
    /* Style horizontal scrollbar for Webkit browsers */
    &::-webkit-scrollbar:horizontal {
        height: 8px; /* height of horizontal scrollbar */
        background-color: rgba(255, 255, 255, 0.1); /* Track color */
        border-radius: 4px;
    }

    &::-webkit-scrollbar-thumb:horizontal {
        background-color: rgba(64, 224, 208, 0.5); /* Thumb color */
        border-radius: 4px;
        &:hover {
            background-color: #40e0d0; /* Darker thumb on hover */
        }
    }
}


table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.row-number-cell {
    width: 40px;
}

th {
    font-weight: 600;
}

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

tfoot td {
    font-weight: 600;
    font-size: 1.1rem;
}

.actions-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.actions-icon {
    width: 20px;
    height: 20px;
    filter: invert(1);
}

/* Style for the action column header */
#table-head th:last-child {
    width: 1%; /* Make it only as wide as its content */
    white-space: nowrap; /* Prevent content from wrapping */
    padding-left: 0.5rem; /* Reduce padding for smaller footprint */
    padding-right: 0.5rem;
}

/* Style for the action cells in the body */
tbody tr td:last-child {
    width: 1%; /* Make it only as wide as its content */
    white-space: nowrap; /* Prevent content from wrapping */
    padding-left: 0.5rem; /* Reduce padding for smaller footprint */
    padding-right: 0.5rem;
    vertical-align: middle; /* Ensure vertical centering */
}

.action-wrapper {
    display: flex;
    align-items: center;
    gap: 5px; /* Space between action buttons */
    justify-content: flex-start;
}

.move-btn {
    font-size: 1.3rem; /* Adjust arrow size for 25x25 buttons */
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    width: 25px; /* Updated width */
    height: 25px; /* Updated height */
    min-width: 25px; /* Prevent shrinking */
    flex-shrink: 0; /* Prevent shrinking */
    padding: 0; /* Reset padding */
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: white;
}

.move-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.add-item-form {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.add-item-form button {
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    border: none;
    background: #fff;
    color: #1a1a1a;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.add-item-form button:hover {
    background: #ddd;
}

/* --- Create Table Modal --- */
#create-table-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1002;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#create-table-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#create-table-modal-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

#create-table-modal-content h2 {
    margin-bottom: 1.5rem;
}

/* Folder Selection Styling */
.folder-selection-wrapper {
    width: 100%;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.input-group select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 1rem;
    appearance: none; /* Custom arrow usually needed but standard is okay */
    cursor: pointer;
}

.input-group select option {
    background: #2a2a2a;
    color: #fff;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
}
.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.create-table-form {
    display: flex;
    flex-direction: column; /* Stack inputs vertically in modal */
    gap: 1rem;
}

.create-table-form input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
}

.create-table-form input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#create-table-save-btn {
    background: #4a90e2;
    color: #fff;
}

#create-table-cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* --- Custom Edit Modal --- */
#edit-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#edit-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#edit-modal-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 90%;
    max-width: 400px;
    text-align: center;
    transform: scale(1);
    transition: transform 0.3s ease-in-out;
}

#edit-modal-overlay.hidden #edit-modal-content {
    transform: scale(0.95);
}

#edit-modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

#edit-modal-content input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 1rem;
    margin-bottom: 1rem;
}

#edit-modal-save-btn {
    background: #4a90e2; /* Blue */
    color: #fff;
}

#edit-modal-save-btn:hover {
    background: #357abd;
}

#edit-modal-cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

#edit-modal-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Row Edit Modal --- */
#row-edit-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1002;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#row-edit-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#row-edit-modal-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh; /* Limit height */
    overflow-y: auto; /* Enable scrolling */
}

#row-edit-form label {
    display: block;
    text-align: left;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

#row-edit-form input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 1rem;
}

/* --- Custom Actions Modal --- */
#actions-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* Remove dark background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#actions-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#actions-modal-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 90%;
    max-width: 400px;
    text-align: center;
    transform: scale(1);
    transition: transform 0.3s ease-in-out;
}

#actions-modal-overlay.hidden #actions-modal-content {
    transform: scale(0.95);
}

#actions-modal-message {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

#actions-modal-message span {
    font-weight: bold;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.modal-buttons button {
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, color 0.3s;
}

#actions-modal-edit-btn, #row-edit-save-btn {
    background: #4a90e2; /* Blue */
    color: #fff;
}

#actions-modal-edit-btn:hover, #row-edit-save-btn:hover {
    background: #357abd;
}

#actions-modal-delete-btn {
    background: #ff6b6b; /* Red */
    color: #fff;
}

#actions-modal-delete-btn:hover {
    background: #ff4f4f;
}

#actions-modal-cancel-btn, #row-edit-cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

#actions-modal-cancel-btn:hover, #row-edit-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Table Settings Modal --- */
#table-settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#table-settings-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#table-settings-modal-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 90%;
    max-width: 500px;
    text-align: center;
    max-height: 90vh; /* Limit height */
    overflow-y: auto; /* Enable scrolling */
}

#table-settings-modal-content h2 {
    margin-bottom: 1.5rem;
}

#table-settings-form h4 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    text-align: left;
}

#table-settings-form input[type="text"],
#table-settings-form input[type="number"],
#table-settings-form select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

#table-settings-form label {
    display: block;
    text-align: left;
    margin: 0.5rem 0;
}

#table-settings-save-btn {
    background: #4a90e2;
    color: #fff;
}

#table-settings-export-btn {
    background: #2ecc71;
    color: #fff;
}

#table-settings-export-btn:hover {
    background: #27ae60;
}

#table-settings-delete-table-btn {
    background: #ff6b6b;
    color: #fff;
}

#table-settings-cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* --- Delete Confirmation Modal --- */
#delete-confirm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1003;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#delete-confirm-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#delete-confirm-modal-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

#delete-confirm-modal-content h2 {
    margin-bottom: 1rem;
}

#delete-confirm-message {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

#delete-confirm-btn {
    background: #ff6b6b;
    color: #fff;
}

#delete-confirm-btn:hover {
    background: #ff4f4f;
}

#delete-cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

#delete-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Generic Message Modal --- */
#message-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000; /* High z-index to show above others */
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#message-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#message-modal-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

#message-modal-content h2 {
    margin-bottom: 1rem;
    color: #40e0d0;
}

#message-modal-text {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

#message-modal-ok-btn {
    background: #40e0d0;
    color: #2a2a2a;
    padding: 0.8rem 2rem;
}
#message-modal-ok-btn:hover {
    background: #2bc4b4;
}

/* Style for alternating table rows */
tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05); /* Very light grey for alternating rows */
}

/* --- Audit Logs Modal --- */
#audit-logs-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#audit-logs-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#audit-logs-modal-content {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 95%;
    max-width: 1000px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.audit-logs-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
}

.audit-logs-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.audit-table th, .audit-table td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    vertical-align: top;
}

.audit-table th {
    background: #1a1a1a; /* Solid dark background to hide scrolling content */
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5); /* Slight shadow for separation */
}

/* No wrap for specific columns */
.audit-table td:nth-child(1), /* Time */
.audit-table td:nth-child(2), /* User */
.audit-table td:nth-child(3) { /* IP */
    white-space: nowrap;
    word-break: keep-all; /* Stellt sicher, dass diese Spalten nicht umbrechen */
    overflow-wrap: normal;
}

.audit-table td:nth-child(4), /* Aktion */
.audit-table td:nth-child(5), /* Tabelle */
.audit-table td:nth-child(6) { /* Details */
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word; /* Notbremse für sehr lange Einzelwörter */
}

/* Diff highlighting */
.diff-old { color: #ff6b6b; text-decoration: line-through; font-size: 0.85rem; margin-right: 5px; }
.diff-new { color: #2ecc71; }
.log-details { font-family: monospace; font-size: 0.85rem; background: rgba(0,0,0,0.3); padding: 5px; border-radius: 4px; }

/* Audit Log Action Colors */
.log-action-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-block;
}

.log-action-add {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.log-action-delete {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.log-action-edit {
    background: rgba(241, 196, 15, 0.2);
    color: #f1c40f;
    border: 1px solid rgba(241, 196, 15, 0.3);
}

.log-action-info {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.3);
}

/* --- Admin & Profile Modals (Shared Overlay) --- */
#admin-modal-overlay,
#profile-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#admin-modal-overlay.hidden,
#profile-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#profile-modal-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

#profile-modal-content h2 {
    margin-bottom: 1.5rem;
}

#profile-modal-content input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 1rem;
    margin-bottom: 1rem;
}

#profile-save-btn {
    background: #4a90e2;
    color: #fff;
}

#profile-cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* --- Admin Panel --- */
#admin-modal-content {
    width: 95%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    text-align: left;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

#admin-modal-content h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.admin-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-section:last-child {
    border-bottom: none;
}

.admin-section h3 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
    color: #40e0d0;
}

/* Create User Form */
.create-user-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr) max-content auto; /* Inputs, Checkbox (compact), Button */
    gap: 1rem;
    align-items: center;
}

@media (max-width: 800px) {
    .create-user-form {
        grid-template-columns: 1fr;
    }

    .create-perm-checkbox-label {
        flex-direction: row-reverse; /* Put text before checkbox */
        justify-content: flex-end;   /* Align to the right for better mobile ergonomics */
        gap: 0.8rem;
    }
}

.create-perm-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap; /* Keep text and checkbox on one line */
    font-size: 0.95rem; /* Slightly smaller text */
    color: rgba(255,255,255,0.8);
}

.create-perm-checkbox-label input[type="checkbox"] {
    margin: 0; /* Remove default margin */
    min-width: 18px; /* Standard size for checkbox */
    min-height: 18px;
    accent-color: #40e0d0; /* Highlight color */
}

/* --- Connection Lost Overlay --- */
#connection-lost-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Slightly darker for emphasis */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Very high z-index to cover everything */
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

#connection-lost-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#connection-lost-content {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 90%;
    max-width: 450px;
    text-align: center;
    color: #fff;
}

#connection-lost-content h2 {
    margin-bottom: 1rem;
    color: #e74c3c; /* Red for alert/error */
    font-size: 1.8rem;
}

#connection-lost-content p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    line-height: 1.5;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border-left-color: #40e0d0;
    animation: spin 1s linear infinite;
    margin: 1.5rem auto 0; /* Center and add space above */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.create-user-form input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
}

#create-user-btn {
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    border: none;
    background: #4a90e2;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

#create-user-btn:hover {
    background: #357abd;
}

/* User List (Cards) */
.users-list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    transition: background 0.3s;
}

.user-card:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.user-info strong {
    font-size: 1.1rem;
    color: #fff;
}

.user-info span {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap; /* Allow buttons to wrap */
}

/* ... existing code ... */

@media (max-width: 768px) {
    /* ... existing rules ... */

    .user-actions button {
        width: 100%;
    }
    .user-actions {
        gap: 0.5rem; /* Reduce gap for vertical stacking */
        flex-direction: column; /* Stack buttons vertically */
    }
}

.user-actions button {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-edit { background: #4a90e2; color: #fff; }
.btn-perms { background: #f39c12; color: #fff; }
.btn-delete { background: #ff6b6b; color: #fff; }
.btn-save { background: #2ecc71; color: #fff; } /* Green */
.btn-save:hover { background: #27ae60; }
.btn-cancel { background: rgba(255, 255, 255, 0.2); color: #fff; }
.btn-cancel:hover { background: rgba(255, 255, 255, 0.3); }

.user-actions button:hover { opacity: 0.9; }

/* Style for buttons inside user edit form */
.user-edit-form button {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s, opacity 0.2s; /* Add transition for hover effect */
}

/* Edit User Form (Inside Card) */
.user-edit-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.user-edit-form input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
}

/* Permissions Dropdown/Area */
.user-permissions-area {
    margin-top: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 10px;
}

.perm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.perm-item:last-child { border-bottom: none; }

.perm-controls label {
    margin-left: 15px;
    font-size: 0.9rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
}

/* NEW: Dashboard Styling */
.dashboard-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.dashboard-table-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #40e0d0;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.dashboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dashboard-item:last-child {
    border-bottom: none;
}

.dash-info {
    flex-grow: 1;
}

.dash-type {
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.7;
}

.dash-content {
    font-size: 0.95rem;
    margin-top: 5px;
    color: #fff;
    word-break: break-all;
}

.dash-user {
    font-size: 0.8rem;
    opacity: 0.5;
    margin-top: 2px;
}

.dash-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-approve, .btn-reject {
    padding: 0.5rem 0.8rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-approve {
    background: #2ecc71; /* Green */
    color: #fff;
}
.btn-approve:hover { background: #27ae60; }

.btn-reject {
    background: #e74c3c; /* Red */
    color: #fff;
}
.btn-reject:hover { background: #c0392b; }

.no-pending-msg {
    text-align: center;
    padding: 2rem;
    opacity: 0.7;
    font-style: italic;
}

/* NEW: Pending Row Styling */
.row-pending-add {
    background-color: rgba(241, 196, 15, 0.15); /* Light yellow tint */
    border-left: 4px solid #f1c40f;
    font-style: italic;
    color: rgba(255, 255, 255, 0.9);
}
.row-pending-add td {
    border-bottom: 1px dashed rgba(241, 196, 15, 0.4);
}

.row-pending-delete {
    background-color: rgba(241, 196, 15, 0.1); /* Light yellow tint */
    border-left: 4px solid #e74c3c; /* Keep red border for delete indication */
    text-decoration: line-through;
    opacity: 0.7;
    color: rgba(255, 255, 255, 0.6);
}
.row-pending-delete td {
    border-bottom: 1px dashed rgba(231, 76, 60, 0.3);
}