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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-main);
    min-height: 100vh;
    color: var(--text-main);
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.admin-header {
    background: var(--bg-header);
    padding: 20px 30px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.admin-header h1 {
    font-size: 1.8rem;
    color: #4caf50;
    letter-spacing: 2px;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.admin-badge {
    background: #f44336;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: #2a2a2a;
    color: #fff;
}

.tab-btn.active {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

/* Tab Content */
.admin-content {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 30px;
    border: 1px solid var(--border);
}

.tab-content {
    display: none;
}

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

/* Controls Bar */
.controls-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.search-input {
    flex: 2;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 1rem;
}

.search-input:focus {
    outline: none;
    border-color: #4caf50;
    background: #333;
}

.filter-select {
    flex: 1;
    padding: 12px 16px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: #4caf50;
}

/* Table */
.table-container {
    overflow-x: auto;
}

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

.admin-table thead {
    background: #2a2a2a;
}

.admin-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #4caf50;
    border-bottom: 2px solid #444;
}

.admin-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #333;
}

.admin-table tbody tr {
    transition: background 0.2s ease;
    cursor: pointer;
}

.admin-table tbody tr:hover {
    background: var(--bg-hover);
}

.admin-table .loading {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

/* Access Level Badges */
.access-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.access-badge.field {
    background: #666;
    color: white;
}

.access-badge.office {
    background: #2196f3;
    color: white;
}

.access-badge.management {
    background: #9c27b0;
    color: white;
}

.access-badge.admin {
    background: #f44336;
    color: white;
}

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.active {
    background: #4caf50;
    color: white;
}

.status-badge.inactive {
    background: #666;
    color: white;
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 6px 12px;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #4caf50;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: #4caf50;
    color: white;
}

.btn-icon.danger {
    color: #f44336;
}

.btn-icon.danger:hover {
    background: #f44336;
    color: white;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #4caf50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

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

.btn-secondary:hover {
    background: #777;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #da190b;
}

/* Permissions Grid */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.access-group {
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.access-header {
    padding: 15px;
    color: white;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.count-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
}

.user-list {
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.user-item {
    padding: 10px;
    background: #1e1e1e;
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item:hover {
    background: #333;
    transform: translateX(5px);
}

.user-item-name {
    font-weight: 600;
}

.user-item-position {
    font-size: 0.85rem;
    color: #888;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

.modal-content.small {
    width: 90%;
    max-width: 500px;
}

.modal-content.large {
    width: 90%;
    max-width: 900px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

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

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #4caf50;
}

.close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: #fff;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #444;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Form Fields */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-section {
    grid-column: 1 / -1;
    margin-top: 20px;
}

.form-section h3 {
    color: #4caf50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #ccc;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4caf50;
    background: #333;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Drag and Drop */
.drop-zone {
    min-height: 100px;
    transition: all 0.3s ease;
}

.user-item[draggable="true"] {
    cursor: move;
}

.user-item[draggable="true"]:active {
    cursor: grabbing;
}

/* Permissions Matrix */
.permissions-matrix td {
    vertical-align: middle;
}

.perm-select {
    width: 100%;
    padding: 6px 10px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
}

.perm-select:focus {
    outline: none;
    border-color: #4caf50;
}

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

/* Collapsible Section */
.collapsible-section {
    margin-bottom: 30px;
}

.collapsible-header {
    background: #2a2a2a;
    padding: 15px 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
    border: 1px solid #444;
    margin-bottom: 0;
}

.collapsible-header:hover {
    background: #333;
}

.collapsible-content {
    padding: 20px;
    border: 1px solid #444;
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: #1e1e1e;
}

/* Access Level Modal Styles */
.access-level-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.access-level-option {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.access-level-option:hover {
    background: #333;
    border-color: #4caf50;
}

.access-level-option input[type="radio"] {
    margin-right: 15px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.access-level-option input[type="radio"]:checked {
    accent-color: #4caf50;
}

.access-level-option.selected {
    background: #333;
    border-color: #4caf50;
}

.option-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.level-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    color: white;
    font-weight: 600;
    font-size: 14px;
    width: fit-content;
}

.level-description {
    color: #999;
    font-size: 13px;
}

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

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

    .admin-header {
        flex-direction: column;
        gap: 15px;
    }
}

/* Holiday Styling */
.standard-holiday-row {
    background-color: rgba(23, 162, 184, 0.05);
}

.standard-holiday-row:hover {
    background-color: rgba(23, 162, 184, 0.1) !important;
}

.badge {
    display: inline-block;
    padding: 0.25em 0.4em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.badge-info {
    color: #fff;
    background-color: #17a2b8;
}

.badge-secondary {
    color: #fff;
    background-color: #6c757d;
}

/* Premium Pattern Grid */
.pattern-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    margin-top: 15px;
}

.pattern-day-card {
    background: #252525;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    cursor: default;
}

.pattern-day-card:hover {
    border-color: #555;
    background: #2a2a2a;
}

.pattern-day-card.active {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pattern-day-card.week2 {
    background: #202020;
}

.pattern-day-card.week2.active {
    background: rgba(76, 175, 80, 0.08);
}

.day-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pattern-day-card.active .day-label {
    color: #4caf50;
}

.unit-selector {
    width: 100%;
    padding: 6px 4px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #eee;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
}

.pattern-day-card.active .unit-selector {
    border-color: #4caf50;
    background: #1e1e1e;
}

.unit-selector:focus {
    outline: none;
    border-color: #4caf50;
}
/* --- Mobile Responsiveness (Phase 14) --- */
@media (max-width: 768px) {
    .admin-container {
        padding: 5px;
    }

    .admin-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
    }

    .tab-btn {
        flex: 0 0 auto;
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .admin-content {
        padding: 15px;
    }

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

    .controls-bar > * {
        width: 100% !important;
        margin-left: 0 !important;
    }

    .search-input, .filter-select {
        flex: none;
    }

    .table-container {
        margin: 0 -15px;
        padding: 0 15px;
        border-radius: 0;
    }

    .admin-table th, .admin-table td {
        padding: 10px;
        font-size: 0.85rem;
    }

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

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

    .modal-content.large, .modal-content.small {
        width: 95%;
        margin: 10px;
    }

    .modal-body {
        padding: 15px;
    }

    .pattern-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}
