/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 24px;
    font-weight: 600;
}

.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: system-ui, sans-serif;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

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

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal Dialog */
.modal-dialog {
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Modal Content */
.modal-content {
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* Modal Header */
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.close {
    background: none;
    border: none;
    font-size: 28px;
    color: #777;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.close:hover {
    background-color: #f5f5f5;
    color: #333;
}

/* Modal Body */
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Modal Footer */
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: system-ui, sans-serif;
    color: #333;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
}

/* Checkbox Labels */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
}

.checkbox-label.small {
    font-size: 13px;
    color: #555;
}

/* Folder name with info icon */
.folder-name-with-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Info Icon with Tooltip */
.info-icon {
    color: #999;
    font-size: 14px;
    cursor: help;
    flex-shrink: 0;
    position: relative;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
}

.info-icon:hover {
    color: #007bff;
    background-color: #f0f0f0;
}

/* Tooltip element (created by JavaScript) */
.info-tooltip {
    position: fixed;
    background-color: #fff;
    color: #333;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 1px solid #ddd;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    font-family: system-ui, sans-serif;
}

.info-tooltip.visible {
    opacity: 1;
}

/* Domain Section */
.domain-section {
    margin-top: 24px;
    transition: opacity 0.2s;
}

.domain-section.hidden {
    display: none;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

/* Domain Container (Two Column Layout) */
.domain-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.domain-container.no-folders {
    grid-template-columns: 1fr;
}

/* Selection Panel */
.selection-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.selection-group {
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    display: flex;
    flex-direction: column;
}

.selection-group.hidden {
    display: none;
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #ddd;
    background-color: #f5f5f5;
}

.group-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0;
    flex: 1;
}

.search-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.search-input {
    width: 180px;
    padding: 6px 28px 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    font-family: system-ui, sans-serif;
    color: #333;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
}

.search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    display: none;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    text-decoration: none;
    user-select: none;
}

.search-clear:hover {
    background-color: #f0f0f0;
    color: #333;
}

.search-clear.visible {
    display: block;
}

.selection-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
}

.selection-list.scrollable {
    max-height: 200px;
    overflow-y: auto;
}

.selection-list.scrollable::-webkit-scrollbar {
    width: 8px;
}

.selection-list.scrollable::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.selection-list.scrollable::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.selection-list.scrollable::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.checkbox-label.hidden {
    display: none;
}

/* Access Summary Panel */
.access-summary {
    padding: 16px;
    background-color: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #ddd;
    position: sticky;
    top: 0;
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.summary-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.summary-badge {
    background-color: #007bff;
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
}

.summary-content {
    font-size: 14px;
    color: #555;
}

.summary-empty {
    color: #777;
    font-style: italic;
    margin: 0;
}

.summary-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.summary-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 16px;
    font-size: 12px;
    color: #0056b3;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .domain-container {
        grid-template-columns: 1fr;
    }

    .access-summary {
        position: static;
    }

    .modal-dialog {
        width: 95%;
    }
}
