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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transition: all 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.sidebar-header i {
    margin-right: 0.5rem;
    color: #ffd700;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu li {
    margin: 0.5rem 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: #ffd700;
}

.menu-item.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: #ffd700;
}

.menu-item i {
    margin-right: 1rem;
    width: 20px;
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    color: white;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.user-info i {
    font-size: 1.5rem;
    margin-right: 0.75rem;
}

.btn-logout {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-logout i {
    margin-right: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-left: 280px;
    transition: margin-left 0.3s ease;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #667eea;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background-color: #f7fafc;
    color: #4c51bf;
}

.content-header {
    background: white;
    padding: 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.content-header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: #2d3748;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.search-box i {
    position: absolute;
    left: 1rem;
    color: #a0aec0;
}

.search-box input {
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 1rem;
    width: 300px;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
}

.search-clear {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.3s ease;
    display: none;
}

.search-clear:hover {
    color: #718096;
}

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

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

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

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

.btn-danger:hover {
    background-color: #c53030;
}

.btn-info {
    background-color: #3182ce;
    color: white;
}

.btn-info:hover {
    background-color: #2c5282;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Content Sections */
.content-section {
    display: none;
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

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

.section-content {
    max-width: 1200px;
    margin: 0 auto;
}

/* Data Tables */
.data-table-container {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 2rem;
}

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

.data-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover {
    background-color: #f7fafc;
}

.data-table .empty-state-row:hover {
    background-color: transparent !important;
}

.data-table .actions {
    display: flex;
    gap: 0.5rem;
}

/* Filters */
.permissions-filters,
.logs-filters {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.form-select,
.form-input {
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    min-width: 150px;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: #667eea;
}

/* Input with button (for NFC reading) */
.input-with-button {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.input-with-button .form-input {
    flex: 1;
}

.input-with-button .btn-icon-read {
    padding: 0.75rem 1rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.input-with-button .btn-icon-read i {
    margin-right: 0.5rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2d3748;
}

.input-with-button .btn-icon-read:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination button {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination button:hover:not(:disabled) {
    background-color: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background-color: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination-info {
    margin: 0 1rem;
    color: #718096;
    font-size: 0.875rem;
}

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

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

.modal-content {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-sm {
    max-width: 400px;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #a0aec0;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #718096;
}

.modal-body {
    padding: 1.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #4a5568;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #718096;
    font-style: italic;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Confirmation Modal Styles */
.confirm-icon {
    text-align: center;
    margin-bottom: 1rem;
}

.confirm-icon i {
    font-size: 3rem;
    color: #e53e3e;
}

#confirm-message {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    color: #4a5568;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 400px;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background-color: #38a169;
}

.toast-error {
    background-color: #e53e3e;
}

.toast-info {
    background-color: #3182ce;
}

.toast-warning {
    background-color: #d69e2e;
}

/* Loading Spinner */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 999;
    backdrop-filter: blur(2px);
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Summary Styles */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.summary-card h4 {
    color: #4a5568;
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.summary-list {
    list-style: none;
}

.summary-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.summary-list li:last-child {
    border-bottom: none;
}

.summary-stat {
    font-size: 2rem;
    font-weight: 600;
    color: #667eea;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .search-box input {
        width: 250px;
    }

    .data-table-container {
        overflow-x: auto;
    }
}

@media (max-width: 768px) {

    /* Show hamburger menu */
    .sidebar-toggle {
        display: block;
    }

    /* Sidebar becomes overlay */
    .sidebar {
        width: 280px;
        position: fixed;
        left: -280px;
        z-index: 1000;
        height: 100vh;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    /* Main content takes full width */
    .main-content {
        margin-left: 0;
    }

    /* Header adjustments */
    .content-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        padding: 1rem;
    }

    .content-header h1 {
        font-size: 1.5rem;
        text-align: center;
        order: 2;
    }

    .sidebar-toggle {
        align-self: flex-start;
        order: 1;
    }

    .header-actions {
        justify-content: center;
        order: 3;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .search-box {
        width: 100%;
        max-width: 300px;
    }

    .search-box input {
        width: 100%;
    }

    /* Button adjustments */
    .btn {
        flex: 1;
        min-width: 120px;
    }

    .permissions-filters,
    .logs-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
    }

    /* Table improvements */
    .data-table {
        font-size: 0.875rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    /* Hide less important columns on mobile */
    .data-table .hide-mobile {
        display: none;
    }

    /* Form improvements for mobile */
    .input-with-button {
        flex-direction: column;
        align-items: stretch;
    }

    .input-with-button .btn-icon-read {
        margin-top: 0.5rem;
        justify-content: center;
    }

    .form-select,
    .form-input {
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {

    .content-header,
    .content-section {
        padding: 1rem;
    }

    .content-header {
        padding: 0.75rem;
    }

    .content-header h1 {
        font-size: 1.25rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Stack action buttons vertically on very small screens */
    .header-actions {
        flex-direction: column;
    }

    .search-box {
        order: 1;
    }

    /* Sidebar adjustments for small screens */
    .sidebar {
        width: 260px;
        left: -260px;
    }

    .sidebar-header {
        padding: 1.5rem 1rem;
    }

    .sidebar-header h2 {
        font-size: 1.25rem;
    }

    .menu-item {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
    }

    .sidebar-footer {
        padding: 1rem;
    }

    /* Form improvements for very small screens */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.375rem;
    }

    .form-select,
    .form-input {
        padding: 0.625rem;
        font-size: 0.875rem;
    }

    .input-with-button .btn-icon-read {
        padding: 0.625rem;
        font-size: 0.875rem;
    }
}

/* Overlay for mobile sidebar */
@media (max-width: 768px) {
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

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