:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --border-color: #ced4da;
    --dark-bg: #343a40;
    --navy-blue: #001f3f;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--light-bg);
    color: #333;
}

/* Resizing State */
body.resizing-active {
    cursor: col-resize !important;
    user-select: none !important;
}

body.resizing-active * {
    transition: none !important;
    cursor: col-resize !important;
}

/* Utility Classes for CSP Compliance */
.d-none {
    display: none !important;
}
.d-inline-block {
    display: inline-block !important;
}
.w-100 {
    width: 100% !important;
}
.w-80 {
    width: 80% !important;
}
.w-60 {
    width: 60% !important;
}
.w-50 {
    width: 50% !important;
}
.w-45 {
    width: 45% !important;
}
.w-40 {
    width: 40% !important;
}
.w-10 {
    width: 10% !important;
}
.w-300px {
    width: 300px !important;
}
.w-200px {
    width: 200px !important;
}
.w-180px {
    width: 180px !important;
}
.w-150px {
    width: 150px !important;
}
.w-120px {
    width: 120px !important;
}
.w-100px {
    width: 100px !important;
}
.w-80px {
    width: 80px !important;
}
.w-50px {
    width: 50px !important;
}
.h-100 {
    height: 100% !important;
}
.flex-1 {
    flex: 1 !important;
}
.min-h-600 {
    min-height: 600px !important;
}
.max-h-500 {
    max-height: 500px !important;
}
.max-w-1000px {
    max-width: 1000px !important;
}
.max-w-500px {
    max-width: 500px !important;
}
.overflow-hidden {
    overflow: hidden !important;
}
.overflow-y-auto {
    overflow-y: auto !important;
}
.p-0 {
    padding: 0 !important;
}
.p-10 {
    padding: 10px !important;
}
.p-20 {
    padding: 20px;
}
.ml-5 {
    margin-left: 5px;
}
.mr-5 {
    margin-right: 5px;
}
.mt-5 {
    margin-top: 5px !important;
}
.mt-10 {
    margin-top: 10px;
}
.mt-15 {
    margin-top: 15px;
}
.mt-20 {
    margin-top: 20px;
}
.mt-30 {
    margin-top: 30px;
}
.m-0 {
    margin: 0 !important;
}
.mb-0 {
    margin-bottom: 0 !important;
}
.mb-5 {
    margin-bottom: 5px !important;
}
.mb-10 {
    margin-bottom: 10px !important;
}
.mb-15 {
    margin-bottom: 15px !important;
}
.mb-20 {
    margin-bottom: 20px !important;
}
.no-decoration {
    text-decoration: none;
}
.text-center {
    text-align: center;
}
.text-danger {
    color: var(--danger-color);
}
.text-success {
    color: var(--success-color) !important;
}
.flex {
    display: flex;
}
.flex-column {
    display: flex;
    flex-direction: column;
}
.flex-wrap {
    flex-wrap: wrap;
}
.flex-between {
    display: flex;
    justify-content: space-between;
}
.flex-end {
    display: flex;
    justify-content: flex-end;
}
.align-center {
    align-items: center;
}
.gap-5 {
    gap: 5px;
}
.gap-10 {
    gap: 10px;
}
.gap-20 {
    gap: 20px;
}
.font-weight-bold {
    font-weight: bold;
}
.font-weight-normal {
    font-weight: normal !important;
}
.font-monospace {
    font-family: monospace !important;
}
.white-space-pre-wrap {
    white-space: pre-wrap !important;
}
.cursor-pointer {
    cursor: pointer !important;
}
.text-small {
    font-size: 0.8rem !important;
}
.text-muted {
    color: var(--secondary-color);
}
.relative {
    position: relative;
}
.bg-light {
    background-color: var(--light-bg) !important;
}

/* Component Styles */
.filter-item {
    min-width: 220px;
}
.checkbox-inline {
    width: auto !important;
}

.filter-select {
    min-width: 200px;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-image: url("../img/cover.svg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

/* Admin Layout */
.admin-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

#sidebar {
    width: 250px;
    background-color: var(--dark-bg);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar-header {
    padding: 20px;
    background-color: #23272b;
}

.sidebar-header h2 {
    margin: 0 0 15px 0;
    font-size: 1.2rem;
}

.sidebar-search {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #454d55;
    background: #343a40;
    color: white;
}

.resource-groups {
    flex: 1;
    overflow-y: auto;
}

.group-title {
    padding: 10px 20px;
    background: #2c3136;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #adb5bd;
}

.resource-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.resource-list li {
    padding: 10px 25px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.resource-list li:hover {
    background-color: #495057;
}
.resource-list li.active {
    background-color: var(--primary-color);
}

.sidebar-footer {
    padding: 15px;
    background-color: #23272b;
    border-top: 1px solid #454d55;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    padding: 15px 25px;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 4px;
}

#content-area {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
}

/* Components */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 20px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-weight: 600;
}

.mandatory-star {
    color: var(--danger-color);
    margin-left: 4px;
}

.hint-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background-color: var(--secondary-color);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    margin-left: 8px;
    cursor: help;
    position: relative;
}

.hint-icon:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    font-size: 12px;
    font-weight: normal;
}

input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 40px !important;
    cursor: pointer;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

input:disabled, select:disabled, textarea:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

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

.btn-small {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.btn-nav {
    background-color: #454d55;
    color: white;
    text-align: left;
    padding: 12px 20px;
}

.btn-nav:hover {
    background-color: #495057;
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.copy-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

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

.copy-btn svg {
    display: block;
}

.copy-btn-floating {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Table */
.table-container {
    overflow-x: auto;
    position: relative;
    font-size: smaller;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 100%;
}

.table-fixed {
    table-layout: fixed;
}

th, td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

th:last-child, td:last-child {
    border-right: none;
}

th {
    background-color: #f1f3f5;
    position: sticky;
    top: 0;
    z-index: 2;
    min-width: 50px;
    overflow: hidden !important;
    user-select: none;
    padding: 0;
}

.header-content {
    padding: 12px;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

th:hover {
    z-index: 100;
    overflow: visible !important;
}

th:hover .header-content {
    position: absolute;
    top: 0;
    left: 0;
    width: max-content;
    min-width: 100%;
    background-color: #f1f3f5 !important;
    box-shadow: none;
    z-index: 101;
}

.resizer {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 8px;
    cursor: col-resize;
    user-select: none;
    z-index: 110;
    background-color: transparent;
    pointer-events: auto;
}

.resizer::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 2px;
    background-color: transparent;
    transition: background-color 0.2s;
}

.resizer:hover::after, .resizer.resizing::after {
    background-color: var(--primary-color);
}

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

.sortable-header:hover {
    background-color: #e9ecef;
}

.sort-icon {
    margin-left: 5px;
    font-size: 0.8rem;
    color: var(--secondary-color);
    pointer-events: none;
}

.empty-table-msg {
    text-align: center;
    padding: 60px 40px;
    color: var(--secondary-color);
    font-style: italic;
    font-size: 1.1rem;
    border-right: none !important;
}

.actions-column {
    width: 140px !important;
    min-width: 140px !important;
    text-align: left !important;
    padding-left: 12px !important;
}

.actions-cell {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal.active {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 25px;
    border-radius: 8px;
    width: 60%;
    max-height: 85vh;
    overflow-y: auto;
}

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

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-range {
    display: flex;
    gap: 5px;
    align-items: center;
}

.filter-range input {
    flex: 1;
    min-width: 100px;
    padding: 6px;
    font-size: 0.85rem;
}

.filter-quick-select {
    padding: 6px;
    font-size: 0.85rem;
    border-color: var(--border-color);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.loading {
    text-align: center;
    padding: 40px;
    font-style: italic;
    color: var(--secondary-color);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 22px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 20px;
}

.chart-widget {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    position: relative;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chart-widget.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary-color);
    cursor: grabbing;
}

.chart-widget.drag-over {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,123,255,0.2);
    border: 2px solid var(--primary-color);
}

.chart-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-widget-title {
    font-weight: bold;
    font-size: 1.1rem;
}

.chart-widget-subtitle {
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-top: 2px;
}

.chart-container {
    flex: 1;
    position: relative;
}

.remove-widget-btn {
    color: var(--danger-color);
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
}

.edit-widget-btn, .refresh-widget-btn {
    color: var(--primary-color);
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 5px;
    margin-right: 5px;
}

.drag-widget-btn {
    cursor: grab;
    color: var(--secondary-color);
    background: none;
    border: none;
    padding: 0 5px;
    margin-right: 5px;
    display: flex;
    align-items: center;
}

.drag-widget-btn:active {
    cursor: grabbing;
}

.edit-widget-btn, .refresh-widget-btn, .remove-widget-btn, .drag-widget-btn {
    transition: color 0.2s, transform 0.1s;
}

.edit-widget-btn:hover, .refresh-widget-btn:hover {
    color: #0056b3;
    transform: scale(1.1);
}

.remove-widget-btn:hover {
    color: #bd2130;
    transform: scale(1.1);
}

.drag-widget-btn:hover {
    color: #333;
    transform: scale(1.1);
}

/* Log Page Specific Styles */
.category-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.btn-category {
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    border: none;
    color: white;
    transition: opacity 0.2s;
}
.btn-category.active {
    outline: 2px solid #000;
    outline-offset: 1px;
}
.cat-all {
    background-color: #6c757d;
}
.cat-access {
    background-color: #17a2b8;
}
.cat-catalina {
    background-color: #17a2b8;
}
.cat-localhost {
    background-color: #17a2b8;
}
.cat-manager {
    background-color: #17a2b8;
}
.cat-other {
    background-color: #ffc107;
    color: #212529;
}

.search-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
}
.search-logs {
    width: 250px;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.directory-info {
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 1.1rem;
}

.btn-view {
    background-color: #198754;
    color: white;
}
.btn-download {
    background-color: #0d6efd;
    color: white;
}

/* Tenant Setup Specific Styles */
.setup-container {
    max-width: 800px;
    margin: 0 auto;
}
.result-area {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    white-space: pre-wrap;
    font-family: monospace;
    max-height: 400px;
    overflow-y: auto;
}

/* Global Notification Toast */
.notification-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #333;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: none;
    align-items: center;
    gap: 15px;
    z-index: 2000;
    max-width: 400px;
    border-left: 5px solid var(--danger-color);
}

.notification-toast.active {
    display: flex;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* JSON Editor Styles */
#json-editor-container {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 10px;
}

.json-row input {
    font-family: monospace;
    font-size: 0.9rem;
}

.json-key {
    background-color: #f8f9fa;
    font-weight: bold;
}

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

.dropdown-display {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 40px;
}

.dropdown-display.disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 2000;
    display: none;
    flex-direction: column;
    margin-top: 2px;
}

.dropdown-menu.active {
    display: flex;
}

.dropdown-search-container {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-search {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

.dropdown-options {
    max-height: 250px;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
}

.dropdown-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.dropdown-option:hover {
    background-color: #f1f3f5;
}

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

.dropdown-load-more {
    padding: 8px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.btn-load-more {
    width: 100%;
    padding: 4px;
    font-size: 0.8rem;
    background: none;
    color: var(--primary-color);
    border: 1px dashed var(--primary-color);
}

.btn-load-more:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    border-radius: 8px;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .header-filter-group label {
        display: none;
    }
    .filter-select {
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
    }

    #sidebar.active {
        transform: translateX(0);
    }

    header {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .header-filter-group {
        order: 3;
        width: calc(33.33% - 7px);
    }

    .filter-select {
        min-width: 0;
        width: 100%;
        font-size: 0.8rem;
        padding: 5px 25px 5px 8px !important;
        background-position: right 5px center;
        background-size: 14px;
    }

    .user-section {
        order: 2;
    }

    #user-display {
        display: none;
    }

    #current-resource-title {
        width: 100%;
        order: 4;
        margin: 5px 0 0 0;
        font-size: 1.1rem;
    }

    #content-area {
        padding: 15px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 15px;
    }

    .search-bar {
        flex-direction: column;
    }

    .filter-item {
        min-width: 0;
        width: 100%;
    }

    .flex-between {
        flex-direction: column;
        gap: 10px;
    }

    .flex-between .flex {
        width: 100%;
        justify-content: space-between;
    }
}
