/* Reset & Base */
:root {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --font-family: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    background-image: radial-gradient(circle at top right, #1e293b 0%, #0f172a 100%);
}

/* Utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-icon {
    background: transparent;
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
}

.login-card .logo {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.login-card h2 {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.input-group {
    margin-bottom: 1rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: #94a3b8;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
    color: white;
    font-family: inherit;
}

.input-group input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.error-message {
    color: var(--danger-color);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
    z-index: 10;
}

.sidebar .brand {
    padding: 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-color);
    border-bottom: 1px solid var(--glass-border);
}

.sidebar nav {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    background: transparent;
    color: #94a3b8;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
}

.user-info {
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: color 0.2s;
}

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

/* Main Content */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.tab-content {
    display: none;
    flex-direction: column;
    height: 100%;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.top-bar {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.top-bar h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* File Manager */
.file-workspace {
    flex: 1;
    display: flex;
    padding: 1rem;
    gap: 1rem;
    overflow: hidden;
}

.file-list {
    width: 300px;
    border-radius: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.file-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s;
}

.file-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.file-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary-color);
}

.file-item .icon {
    color: #94a3b8;
}

.file-item .name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-container {
    flex: 1;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-toolbar {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

#file-editor {
    flex: 1;
    background: transparent;
    border: none;
    color: #e2e8f0;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

/* Scheduler */
.scheduler-workspace {
    flex: 1;
    margin: 1rem;
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 1rem;
    border-radius: 0.5rem;
    color: #93c5fd;
}

.json-editor {
    flex: 1;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    color: #e2e8f0;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', monospace;
    resize: none;
    outline: none;
}

.json-editor:focus {
    border-color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 0.5rem;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .sidebar .brand {
        border-bottom: none;
        padding: 0.5rem;
    }

    .sidebar nav {
        flex-direction: row;
        padding: 0;
    }

    .user-info {
        border-top: none;
        padding: 0 0.5rem;
    }

    .file-workspace {
        flex-direction: column;
    }

    .file-list {
        width: 100%;
        height: 150px;
    }
}

/* Smart Editors */
.smart-editor {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    margin-top: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.smart-editor h2 {
    margin-bottom: 1.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
    margin-bottom: 1rem;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-color);
}

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

/* Theme Select */
.theme-select {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
    min-width: 200px;
}

.theme-select:focus {
    border-color: var(--primary-color);
}

/* Scheduler GUI */
.scheduler-gui {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.scheduler-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 8px;
    align-items: center;
}

.scheduler-row input,
.scheduler-row select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--danger-color);
}

.btn-add {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--text-primary);
}

/* Permissions Table */
.permissions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

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

.permissions-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.permissions-table input[type="text"] {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    width: 100%;
}

.permissions-checks {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.perm-check {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.perm-check:hover {
    background: rgba(255, 255, 255, 0.1);
}

.perm-check input {
    accent-color: var(--primary-color);
}

/* Permissions Editor - UUID Management */
.permissions-editor {
    padding: 1rem;
    text-align: left;
    overflow-y: auto;
    max-height: calc(100vh - 250px);
}

.permissions-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.permissions-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
}

.permissions-section h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.permissions-section .section-desc {
    color: #94a3b8;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.allowed-section {
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.denied-section {
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.user-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-uuid {
    flex: 0 0 320px;
}

.user-uuid .uuid-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-color);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
}

.user-uuid .uuid-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.user-permissions {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.perm-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.7rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    user-select: none;
}

.perm-checkbox:hover {
    background: rgba(255, 255, 255, 0.1);
}

.perm-checkbox input {
    accent-color: var(--primary-color);
    cursor: pointer;
}

.perm-checkbox input:checked + span {
    color: var(--primary-color);
}

.user-row .btn-delete {
    flex-shrink: 0;
    color: #94a3b8;
}

.user-row .btn-delete:hover {
    color: var(--danger-color);
    background: rgba(244, 67, 54, 0.1);
}