/* Moduls Control Server - Main Stylesheet */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background: var(--background-gradient);
    min-height: 100vh;
}

/* Layout Structure */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo:hover {
    color: var(--warning-color);
    transition: var(--transition);
}

/* Navigation */
.nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.1);
}

.nav-link:hover, .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.nav-icon {
    margin-right: 0.35rem;
    display: inline-block;
}

.nav-label {
    display: inline-block;
    vertical-align: middle;
}

/* Dropdown Navigation */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-toggle:hover,
.nav-dropdown.active .dropdown-toggle {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.nav-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    background: rgba(44, 62, 80, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    min-width: 220px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    z-index: 1001;
}

.nav-dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    color: white;
    text-decoration: none;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.dropdown-item.active {
    background: rgba(52, 152, 219, 0.3);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #2da44e;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px #2da44e;
}

/* Header Layout Improvements */
.header-nav-container {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

/* User Info Section */
.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: white;
    font-size: 0.9rem;
}

.user-profile-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    background: rgba(255, 255, 255, 0.1);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.user-profile-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    color: var(--warning-color);
}

.logout-btn {
    background: rgba(231, 76, 60, 0.2) !important;
    border: 1px solid rgba(231, 76, 60, 0.3) !important;
    padding: 0.25rem 0.75rem !important;
    font-size: 0.8rem !important;
    white-space: nowrap;
}

.logout-btn:hover {
    background: rgba(231, 76, 60, 0.3) !important;
    transform: translateY(-2px);
}

/* Footer Improvements */
.session-info {
    font-size: 0.8rem;
    opacity: 0.8;
    margin: 0;
}

/* Navigation Improvements */
.nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Mobile Responsive Improvements */
@media (max-width: 768px) {
    .header-nav-container {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .user-info {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 0.5rem;
        width: 100%;
    }
    
    .nav {
        order: 2;
        justify-content: center;
        width: 100%;
    }
    
    .user-info {
        order: 1;
        justify-content: center;
    }
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Card Styles */
.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.card-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.card-header h1, .card-header h2, .card-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* Grid System */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-online {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.status-offline {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.status-warning {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Command Styles */
.command-block {
    background: var(--light-color);
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
    position: relative;
}

.command-name {
    font-weight: bold;
    color: var(--danger-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
}

.command-desc {
    color: #666;
    margin-bottom: 0.75rem;
}

.command-example {
    background: var(--secondary-color);
    color: #ecf0f1;
    padding: 0.75rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: pre;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #1a252f;
    transform: translateY(-1px);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
}

.btn-outline-secondary:hover {
    background: var(--secondary-color);
    color: white;
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-copy:hover {
    background: #2980b9;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.table th, .table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.table tbody tr:hover {
    background: rgba(52, 152, 219, 0.05);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    border-left: 4px solid;
}

.alert-info {
    background: rgba(23, 162, 184, 0.1);
    border-color: var(--info-color);
    color: #0c5460;
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    border-color: var(--warning-color);
    color: #856404;
}

.alert-success {
    background: rgba(39, 174, 96, 0.1);
    border-color: var(--success-color);
    color: #155724;
}

/* Footer */
.footer {
    background: rgba(0, 0, 0, 0.2);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        justify-content: center;
        width: 100%;
    }
    
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.p-0 { padding: 0; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* Notification System */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 600;
    z-index: 10000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 300px;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background: var(--success-color);
}

.notification-error {
    background: var(--danger-color);
}

.notification-info {
    background: var(--primary-color);
}

/* Card Management Styles */
.card-management-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    min-height: 80vh;
}

.modules-section {
    display: flex;
    flex-direction: column;
}

.modules-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.module-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    overflow: hidden;
    transition: all 0.3s ease;
}

.module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.module-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.module-actions .btn {
    width: 100%;
    justify-content: center;
}

.module-relays {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.module-relays-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(17, 24, 39, 0.75);
}

.module-relays-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.module-relay-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.75rem;
    font-size: 0.88rem;
    color: rgba(17, 24, 39, 0.85);
}

.module-relay-item .relay-id {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 2.5rem;
}

.module-relay-item .relay-label {
    color: rgba(17, 24, 39, 0.6);
    font-style: italic;
}

.module-relays-empty {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: rgba(17, 24, 39, 0.6);
}


.module-relays-editable .module-relay-item {
    align-items: center;
}

.module-relays-editable .module-relay-item input {
    flex: 1 1 150px;
    min-width: 140px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    transition: var(--transition);
}

.module-relays-editable .module-relay-item input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.module-relays-note {
    font-size: 0.78rem;
    color: rgba(17, 24, 39, 0.55);
}


/* Notification System */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    box-shadow: var(--card-shadow);
    animation: slideInRight 0.3s ease-out;
    min-width: 300px;
    max-width: 500px;
}

.notification-info {
    background: var(--primary-color);
}

.notification-success {
    background: var(--success-color);
}

.notification-warning {
    background: var(--warning-color);
}

.notification-error {
    background: var(--danger-color);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced Card Management Styles */
.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.stat-label {
    color: var(--dark-color);
    font-weight: 500;
}

.stat-value {
    color: var(--primary-color);
    font-weight: bold;
}

.card-header-actions {
    display: flex;
    gap: 0.5rem;
}

.card-list, .modules-grid, .groups-list {
    max-height: 400px;
    overflow-y: auto;
}

.card-item, .module-item, .group-item {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.card-item:hover, .module-item:hover, .group-item:hover {
    box-shadow: var(--card-shadow);
    transform: translateY(-1px);
}

.card-item.assigned {
    border-left: 4px solid var(--success-color);
}

.card-item.unassigned {
    border-left: 4px solid var(--warning-color);
}

.card-item-header, .module-header, .group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.card-title-section, .group-title-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.card-actions-header, .group-actions-header {
    display: flex;
    gap: 0.25rem;
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.btn-edit:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.btn-delete:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

.card-item-body, .module-body, .group-body {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.card-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

.card-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-detail label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-color);
    text-transform: uppercase;
}

.card-detail span {
    font-weight: 500;
    color: var(--dark-color);
}

.relay-indicator {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    background: rgba(52, 152, 219, 0.1);
    color: var(--primary-color);
}

.relay-1 { background: rgba(52, 152, 219, 0.1); color: #3498db; }
.relay-2 { background: rgba(39, 174, 96, 0.1); color: #27ae60; }
.relay-3 { background: rgba(243, 156, 18, 0.1); color: #f39c12; }
.relay-4 { background: rgba(231, 76, 60, 0.1); color: #e74c3c; }

.status-active {
    color: var(--success-color);
    font-weight: 600;
}

.status-inactive {
    color: var(--danger-color);
    font-weight: 600;
}

.group-badge {
    background: rgba(142, 68, 173, 0.1);
    color: #8e44ad;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.group-description {
    font-style: italic;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.group-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
}

.group-detail {
    display: flex;
    flex-direction: column;
}

.group-detail label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-color);
}

.card-item-actions, .module-actions, .group-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
}

.status-assigned {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
}

.status-free {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.activity-logs {
    max-height: 300px;
    overflow-y: auto;
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.log-time {
    font-size: 0.8rem;
    color: var(--secondary-color);
    white-space: nowrap;
    margin-right: 1rem;
}

.log-content {
    flex: 1;
    font-size: 0.9rem;
}

.no-groups-message {
    text-align: center;
    padding: 2rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.badge {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
}

.badge-secondary {
    background: var(--secondary-color);
}

.text-small {
    font-size: 0.8rem;
}

.text-muted {
    color: var(--secondary-color);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.tab-button {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--secondary-color);
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Card History */
.card-history-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.history-timeline {
    max-height: 400px;
    overflow-y: auto;
}

.history-entry {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    border-left: 3px solid var(--primary-color);
    margin-bottom: 0.5rem;
    background: rgba(52, 152, 219, 0.05);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.history-time {
    font-size: 0.8rem;
    color: var(--secondary-color);
    white-space: nowrap;
    min-width: 140px;
    font-weight: 500;
}

.history-content {
    flex: 1;
}

/* Group Management */
.group-card-item, .group-module-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    background: white;
}

.group-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.stat-card h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 0.5rem;
}

/* Spinner Animation */
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design for Card Management */
@media (max-width: 1024px) {
    .card-management-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .modules-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
    }
    
    .card-details-grid {
        grid-template-columns: 1fr;
    }
    
    .card-item-actions, .group-actions {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .group-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Card-Management Module Header */
.module-item .module-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white !important;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.module-item .module-header strong {
    color: white !important;
}

.module-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.module-name {
    background: none;
    border: none;
    color: white;
    font: inherit;
    outline: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.module-name:focus {
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.module-status {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
}

.module-status.online {
    background: rgba(46, 204, 113, 0.2);
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.module-status.offline {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.module-body {
    padding: 1rem;
}

.module-info {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.card-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    min-height: 120px;
    transition: all 0.3s ease;
    background: var(--light-bg);
}

.card-drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(52, 152, 219, 0.1);
}

.drop-zone-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.assigned-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.assigned-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.card-code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary-color);
}

.card-name {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.remove-card-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.remove-card-btn:hover {
    background: rgba(231, 76, 60, 0.1);
}

.drop-indicator {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

/* Cards Sidebar */
.cards-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.cards-container, .groups-container {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    overflow: hidden;
}

.cards-header, .groups-header {
    background: var(--light-bg);
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cards-header h3, .groups-header h3 {
    margin: 0;
}

.cards-list, .groups-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
}

.card-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    background: white;
    cursor: grab;
    transition: all 0.3s ease;
}

.card-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-grow: 1;
}

.card-name-input {
    border: none;
    outline: none;
    font-size: 0.875rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.card-name-input:focus {
    background: var(--light-bg);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-small:hover {
    transform: scale(1.1);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

/* Group Cards */
.group-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    background: white;
    overflow: hidden;
}

.group-header {
    background: var(--light-bg);
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.group-name-input {
    border: none;
    outline: none;
    font-weight: 600;
    background: none;
    flex-grow: 1;
}

.group-modules {
    padding: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.module-tag {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.group-drop-zone {
    margin: 0.75rem;
    min-height: 60px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .card-management-container {
        grid-template-columns: 1fr;
    }
    
    .cards-sidebar {
        order: -1;
    }
    
    .modules-container {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* Spinner Animation */
.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-indicator.status-online {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(39, 174, 96, 0.3);
}

.status-indicator.status-offline {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.status-indicator.status-warning {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.status-indicator.status-error {
    background: rgba(231, 76, 60, 0.2);
    color: var(--danger-color);
    border: 1px solid rgba(231, 76, 60, 0.4);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* Footer Styles */
.footer {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: auto;
    padding: 1rem 0;
    color: white;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.session-info {
    font-size: 0.8rem;
    opacity: 0.8;
    margin: 0;
}

.footer-credits {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Form Enhancements */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Real-Time Notification Styles */
.real-time-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    z-index: 1000;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 300px;
    word-wrap: break-word;
}

.real-time-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.real-time-notification::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-radius: 8px;
    pointer-events: none;
}

/* Real-Time Status Indicator */
.status-indicator.real-time {
    position: relative;
}

.status-indicator.real-time::after {
    content: '●';
    position: absolute;
    top: -2px;
    right: -8px;
    color: #4CAF50;
    font-size: 12px;
    animation: pulse-realtime 2s infinite;
}

@keyframes pulse-realtime {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* WebSocket Connection Status */
.ws-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 999;
    transition: all 0.3s ease;
}

.ws-status.connected {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.ws-status.disconnected {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.ws-status.connecting {
    background: rgba(255, 152, 0, 0.1);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}


/* ------------------------------------------------------------
   Management Pages Styling
   ------------------------------------------------------------ */
.profile-container,
.user-management-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-header,
.manager-overview-section,
.create-user-section {
    position: relative;
    background: rgba(255, 255, 255, 0.92);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(255, 255, 255, 0.45);
    overflow: hidden;
}

.profile-header::after,
.manager-overview-section::after,
.create-user-section::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--background-gradient);
    opacity: 0.18;
    z-index: 0;
}

.profile-header > *,
.manager-overview-section > *,
.create-user-section > * {
    position: relative;
    z-index: 1;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    background: rgba(255, 255, 255, 0.65);
    display: grid;
    place-items: center;
    font-size: 2.5rem;
    color: var(--primary-color);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.profile-header h1,
.profile-header p {
    color: var(--secondary-color);
}

.profile-header .role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.85);
    color: var(--secondary-color);
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.85rem;
    box-shadow: var(--card-shadow);
}

.info-section,
.profile-form,
.search-filter,
.user-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.info-section h3,
.profile-form h2,
.create-user-section h2,
.manager-overview-section h2 {
    font-size: 1.2rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.info-grid,
.form-grid,
.create-form,
.user-details,
.stats-section,
.manager-cards {
    display: grid;
    gap: 1.25rem;
}

.info-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-grid,
.create-form {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.stats-section {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.manager-cards {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.info-item,
.user-detail {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--secondary-color);
}

.password-section {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 2rem;
    padding-top: 2rem;
}

.btn-group,
.user-actions,
.filter-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-group .btn,
.user-actions .btn {
    min-width: 160px;
}

#userModuleTokensTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#userModuleTokensTable th,
#userModuleTokensTable td {
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    text-align: left;
}

#userModuleTokensTable th {
    background: rgba(17, 24, 39, 0.04);
    font-weight: 600;
    color: var(--secondary-color);
}

.user-management-container .form-group label,
.profile-form label,
.create-form .form-group label {
    font-weight: 500;
    color: var(--secondary-color);
    margin-bottom: 0.4rem;
    display: inline-block;
}

.create-form .form-group input,
.create-form .form-group select,
.filter-controls input,
.filter-controls select,
.profile-form input,
.profile-form textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.85);
    transition: var(--transition);
}

.create-form .form-group input:focus,
.create-form .form-group select:focus,
.filter-controls input:focus,
.filter-controls select:focus,
.profile-form input:focus,
.profile-form textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
    outline: none;
}

.stat-card {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    border-top: 4px solid var(--primary-color);
    transition: var(--transition);
}

.stat-card:nth-child(2) { border-top-color: var(--success-color); }
.stat-card:nth-child(3) { border-top-color: var(--warning-color); }
.stat-card:nth-child(4) { border-top-color: var(--info-color); }

.stat-card h3 {
    font-size: 2rem;
    margin-bottom: 0.35rem;
    color: var(--secondary-color);
}

.stat-card p {
    margin: 0;
    color: rgba(17, 24, 39, 0.6);
    font-size: 0.9rem;
}

.user-card {
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.user-card.admin { border-left-color: var(--danger-color); }
.user-card.manager { border-left-color: var(--warning-color); }
.user-card.customer { border-left-color: var(--success-color); }

.user-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.user-info h3 {
    margin: 0;
    color: var(--secondary-color);
    font-size: 1.1rem;
}

.user-details {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    font-size: 0.9rem;
    color: rgba(17, 24, 39, 0.7);
}

.user-detail.manager-info {
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid var(--primary-color);
    padding: 0.4rem 0.6rem;
    border-radius: var(--border-radius);
}

.user-detail.manager-info.unassigned {
    background: rgba(220, 53, 69, 0.08);
    border-left-color: var(--danger-color);
}

.manager-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.group-description {
    color: rgba(17, 24, 39, 0.65);
    margin: 0.35rem 0 0;
    font-size: 0.88rem;
}

.group-actions .btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .profile-header,
    .profile-form,
    .info-section,
    .search-filter,
    .user-card,
    .manager-card,
    .create-user-section,
    .manager-overview-section {
        padding: 1.25rem;
    }

    .btn-group {
        flex-direction: column;
    }
}

/* ------------------------------------------------------------
   Card Management Enhancements
   ------------------------------------------------------------ */
.highlight-success {
    background-color: #d4edda !important;
    border-left: 4px solid var(--success-color) !important;
    transition: var(--transition);
    animation: pulseSuccess 0.5s ease-in-out;
}

.highlight-warning {
    background-color: #fff3cd !important;
    border-left: 4px solid var(--warning-color) !important;
    transition: var(--transition);
    animation: pulseWarning 0.5s ease-in-out;
}

.highlight-error {
    background-color: #f8d7da !important;
    border-left: 4px solid var(--danger-color) !important;
    transition: var(--transition);
    animation: pulseError 0.5s ease-in-out;
}

@keyframes pulseSuccess {
    0% { transform: scale(1); background-color: var(--success-color); }
    50% { transform: scale(1.02); background-color: #34ce57; }
    100% { transform: scale(1); background-color: #d4edda; }
}

@keyframes pulseWarning {
    0% { transform: scale(1); background-color: var(--warning-color); }
    50% { transform: scale(1.02); background-color: #ffcd39; }
    100% { transform: scale(1); background-color: #fff3cd; }
}

@keyframes pulseError {
    0% { transform: scale(1); background-color: var(--danger-color); }
    50% { transform: scale(1.02); background-color: #e4606d; }
    100% { transform: scale(1); background-color: #f8d7da; }
}

.scan-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
    background-color: var(--success-color);
    animation: blink 1s infinite;
}

.scan-indicator.failed {
    background-color: var(--danger-color);
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.stat-number.updating {
    animation: countUp 0.5s ease-out;
}

@keyframes countUp {
    from { transform: scale(1.2); color: var(--primary-color); }
    to { transform: scale(1); color: inherit; }
}

.card-scan-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--background-gradient);
    color: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
    z-index: 1050;
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
}

.card-scan-toast.success { background: linear-gradient(135deg, #16a085 0%, #2ecc71 100%); }
.card-scan-toast.warning { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.card-scan-toast.error { background: linear-gradient(135deg, #fc466b 0%, #3f5efb 100%); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.module-status.live-update {
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
}

.card-row.recently-assigned {
    background: linear-gradient(90deg, rgba(248, 249, 250, 1) 0%, rgba(223, 236, 255, 0.75) 50%, rgba(248, 249, 250, 1) 100%);
    background-size: 200% 100%;
    animation: assignmentFlow 3s ease-in-out;
}

@keyframes assignmentFlow {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.groups-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.group-item {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--border-radius);
    padding: 0.9rem 1.1rem;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--card-shadow);
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.group-title-section {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.group-title-section .badge {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary-color);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
}

.group-title-section .badge-secondary {
    background: rgba(148, 163, 184, 0.18);
    color: rgba(17, 24, 39, 0.65);
}

.group-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .card-scan-toast {
        top: 10px;
        right: 10px;
        left: 10px;
        min-width: auto;
    }
}

/* ========================================
   Dashboard Stats Styles
   ======================================== */

#stats-overview {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid #e1e4e8;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.9rem;
    color: #57606a;
    font-weight: 500;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #24292f;
}

.activity-item {
    transition: background-color 0.2s;
}

.activity-item:hover {
    background-color: #f6f8fa;
}

.activity-item:last-child {
    border-bottom: none !important;
}

/* Grid Layouts */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ========================================
   Module Management Page Styles
   ======================================== */

.module-card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.module-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e1e4e8;
    background: linear-gradient(135deg, #f6f8fa 0%, #ffffff 100%);
}

.module-title-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.module-icon {
    font-size: 1.5rem;
}

.module-name-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.module-name-input {
    font-size: 1.1rem;
    font-weight: 600;
    border: 1px solid transparent;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    background: transparent;
}

.module-name-input:hover {
    background: #f6f8fa;
    border-color: #d0d7de;
}

.module-name-input:focus {
    outline: none;
    background: #fff;
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.module-id-label {
    font-size: 0.75rem;
    color: #57606a;
    font-weight: 400;
}

.module-status {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.module-status.online {
    background: #dafbe1;
    color: #1a7f37;
}

.module-status.offline {
    background: #ffebe9;
    color: #cf222e;
}

.module-body {
    padding: 1.25rem;
}

.module-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: #57606a;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.info-value {
    font-size: 0.9rem;
    color: #24292f;
    font-family: 'SFMono-Regular', Consolas, monospace;
}

.module-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid #e1e4e8;
}

.modules-toolbar input,
.modules-toolbar select {
    transition: all 0.2s;
}

.modules-toolbar input:focus,
.modules-toolbar select:focus {
    outline: none;
    border-color: #0969da !important;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

/* ========================================
   Firmware Update Progress Bar
   ======================================== */

.firmware-progress-container {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f6f8fa 0%, #ffffff 100%);
    border: 1px solid #d0d7de;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.firmware-progress-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.firmware-progress-icon {
    font-size: 1.25rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.firmware-progress-stage {
    font-weight: 600;
    font-size: 0.9rem;
    color: #24292f;
}

.firmware-progress-bar {
    width: 100%;
    height: 24px;
    background: #e1e4e8;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.firmware-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0d6efd 0%, #0b5ed7 100%);
    border-radius: 12px;
    transition: width 0.3s ease, background-color 0.3s ease;
    position: relative;
    overflow: hidden;
}

.firmware-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.3) 50%,
        transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.firmware-progress-message {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #57606a;
    text-align: center;
    font-style: italic;
}

/* Progress Bar Status Colors */
.firmware-progress-fill[style*="background-color: rgb(220, 53, 69)"],
.firmware-progress-fill[style*="background-color: #dc3545"] {
    background: linear-gradient(90deg, #dc3545 0%, #c82333 100%) !important;
}

.firmware-progress-fill[style*="background-color: rgb(40, 167, 69)"],
.firmware-progress-fill[style*="background-color: #28a745"] {
    background: linear-gradient(90deg, #28a745 0%, #218838 100%) !important;
}

.firmware-progress-fill[style*="background-color: rgb(13, 110, 253)"],
.firmware-progress-fill[style*="background-color: #0d6efd"] {
    background: linear-gradient(90deg, #0d6efd 0%, #0b5ed7 100%) !important;
}

/* Animation for completed state */
@keyframes fadeOut {
    0% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

.firmware-progress-container.completed {
    animation: fadeOut 5s forwards;
}

/* Responsive Design */
@media (max-width: 768px) {
    .firmware-progress-container {
        padding: 0.75rem;
    }

    .firmware-progress-bar {
        height: 20px;
    }

    .firmware-progress-icon {
        font-size: 1rem;
    }

    .firmware-progress-stage {
        font-size: 0.8rem;
    }
}



/* Clickable Badge für Gruppenkarten */
.badge.clickable {
    cursor: pointer !important;
    transition: all 0.2s ease;
    user-select: none;
}

.badge.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    background-color: #357abd !important;
}

/* Group Cards Popup */
.cards-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.card-popup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f5f5f5;
    border-radius: 4px;
    border-left: 3px solid #4a90e2;
}

.card-popup-item .card-code {
    font-weight: 600;
    color: #2c3e50;
}

.card-popup-item .card-info {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.popup-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
    text-align: right;
}


/* Kompaktes Karten-Design */
.card-item-compact {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #4a90e2;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-item-compact:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.card-item-compact.unassigned {
    border-left-color: #95a5a6;
    background: #f8f9fa;
}

.card-compact-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 200px;
}

.card-compact-icon {
    font-size: 1.5rem;
}

.card-compact-info {
    display: flex;
    flex-direction: column;
}

.card-compact-code {
    font-weight: 600;
    font-size: 1rem;
    color: #2c3e50;
}

.card-compact-name {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.card-compact-middle {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    flex-wrap: wrap;
}

.card-compact-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.compact-label {
    font-size: 0.75rem;
    color: #95a5a6;
    text-transform: uppercase;
    font-weight: 500;
}

.compact-value {
    font-size: 0.9rem;
    color: #2c3e50;
}

.group-badge-mini {
    background: #e8f4f8;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.card-compact-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.card-compact-status {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.card-compact-status.active {
    background: #d4edda;
    color: #155724;
}

.card-compact-status.inactive {
    background: #f8d7da;
    color: #721c24;
}

.card-compact-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-compact {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: transform 0.2s ease;
}

.btn-icon-compact:hover {
    transform: scale(1.2);
}

.btn-icon-compact.btn-danger:hover {
    filter: drop-shadow(0 0 4px rgba(220, 53, 69, 0.5));
}

.btn-icon-compact.btn-success:hover {
    filter: drop-shadow(0 0 4px rgba(40, 167, 69, 0.5));
}

/* Responsive Design */
@media (max-width: 1024px) {
    .card-item-compact {
        flex-wrap: wrap;
    }
    
    .card-compact-middle {
        width: 100%;
        padding-left: 3rem;
    }
    
    .card-compact-right {
        width: 100%;
        justify-content: flex-end;
        padding-left: 3rem;
    }
}

