/* Company Tab Specific Styling for AMD Construction Pro */

/* --- Main Company Layout --- */
#company-tab {
    height: 100dvh;
    width: 100vw;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #f4f6fa;
}

.company-dashboard-layout {
    display: grid;
    grid-template-columns: minmax(320px, 380px) 1fr;
    gap: 0;
    height: 100%;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #f4f6fa;
}

/* --- Left Sidebar --- */
.company-sidebar {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e1e5e9;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    border-bottom: 1px solid #f1f3f5;
}

.sidebar-title {
    padding: 16px 20px 12px 20px;
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-title i {
    font-size: 12px;
    color: var(--color-primary);
}

/* --- Company Overview Card --- */
.company-overview-card {
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.company-overview-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.company-logo {
    position: relative;
    z-index: 1;
    margin-bottom: 16px;
}

.company-logo img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.company-basic-info {
    position: relative;
    z-index: 1;
}

.company-basic-info h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.company-basic-info p {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

.company-status {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.active {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.license-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: rgba(23, 162, 184, 0.2);
    color: #17a2b8;
    border: 1px solid rgba(23, 162, 184, 0.3);
}

/* --- Company Navigation --- */
.company-nav {
    padding: 0;
}

.nav-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f1f3f5;
    color: #495057;
}

.nav-item:hover {
    background: #f8f9fa;
    color: var(--color-primary);
}

.nav-item.active {
    background: rgba(13, 110, 253, 0.1);
    color: var(--color-primary);
    border-right: 3px solid var(--color-primary);
    font-weight: 500;
}

.nav-item i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.nav-item span {
    font-size: 14px;
}

/* --- Quick Stats --- */
.quick-stats {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* --- Main Content Area --- */
.company-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f4f6fa;
}

/* --- Company Header --- */
.company-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.header-title-section h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
    color: white;
}

.header-title-section p {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.4;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.header-actions .search-input-wrapper {
    flex: 1;
    min-width: 200px;
}

.header-actions .filter-dropdown {
    min-width: 120px;
}

.header-actions .btn {
    white-space: nowrap;
}

/* --- Company Sections --- */
.company-section {
    display: none;
    padding: 30px;
    flex: 1;
    overflow-y: auto;
}

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

.section-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e1e5e9;
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
}

.card-header h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

.card-header p {
    margin: 0;
    font-size: 14px;
    color: #6c757d;
    line-height: 1.4;
}

.card-content {
    padding: 30px;
}

/* --- Forms --- */
.company-form {
    width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.span-2 {
    grid-column: span 2;
}

.form-group.span-3 {
    grid-column: span 3;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 16px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* --- Logo Upload Area --- */
.logo-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.logo-upload-area:hover {
    border-color: var(--color-primary);
    background: rgba(13, 110, 253, 0.02);
}

.logo-preview {
    margin-bottom: 16px;
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-preview img {
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.upload-placeholder {
    color: #6c757d;
}

.upload-placeholder i {
    font-size: 32px;
    margin-bottom: 12px;
    color: #dee2e6;
}

.upload-placeholder p {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 500;
}

.upload-placeholder small {
    font-size: 12px;
    color: #6c757d;
}

.logo-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* --- Grids --- */
.locations-grid,
.licenses-grid,
.insurance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.departments-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- Users Table --- */
.users-controls {
    margin-bottom: 24px;
}

.search-and-filter {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 14px;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
}

.filter-select {
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    min-width: 140px;
}

.users-table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.users-table thead {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
}

.users-table th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.users-table td {
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.users-table tbody tr:hover {
    background: #f8f9fa;
}

/* --- Content Cards and Elements --- */

/* User info in table */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar img,
.avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-placeholder {
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 2px;
}

.user-email {
    font-size: 12px;
    color: #6c757d;
}

.user-actions {
    display: flex;
    gap: 4px;
}

/* Role and status badges */
.role-badge,
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: inline-block;
}

.role-badge.role-admin {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.role-badge.role-manager {
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
}

.role-badge.role-estimator {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.role-badge.role-foreman {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.role-badge.role-viewer {
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
}

.status-badge.status-active {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.status-badge.status-inactive {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.status-badge.status-pending {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

/* Location cards */
.location-card,
.department-card,
.license-card,
.insurance-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.location-card:hover,
.department-card:hover,
.license-card:hover,
.insurance-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.location-header,
.department-header,
.license-header,
.insurance-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 10px;
}

.location-header h4,
.department-header h4,
.license-header h4,
.insurance-header h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.location-type,
.department-info p {
    font-size: 12px;
    color: #6c757d;
    background: #f8f9fa;
    padding: 2px 8px;
    border-radius: 12px;
    margin: 0;
}

.location-status {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.location-status.active {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.location-status.inactive {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.location-details,
.department-details,
.license-details,
.insurance-details {
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.detail-item i {
    color: var(--color-primary);
    width: 14px;
    font-size: 12px;
}

.detail-label {
    font-weight: 500;
    color: #495057;
    min-width: 80px;
}

.detail-value {
    color: #6c757d;
}

.location-actions,
.department-actions,
.license-actions,
.insurance-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Department specific styles */
.department-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.department-stats {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: flex-end;
}

.department-stats .stat {
    text-align: center;
}

.department-stats .stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary);
}

.department-stats .stat-label {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Backup specific styles */
.backup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.backup-item:hover {
    background: rgba(13, 110, 253, 0.02);
}

.backup-item:last-child {
    border-bottom: none;
}

.backup-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.backup-date {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.backup-size {
    font-size: 12px;
    color: #6c757d;
}

.backup-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.backup-status.status-success {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.backup-status.status-failed {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
}

.empty-state i {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Loading states */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e9ecef;
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

.notification {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 12px;
    border-left: 4px solid var(--color-primary);
    transform: translateX(420px);
    opacity: 0;
    transition: all 0.3s ease;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.hide {
    transform: translateX(420px);
    opacity: 0;
}

.notification-success {
    border-left-color: #28a745;
}

.notification-error {
    border-left-color: #dc3545;
}

.notification-warning {
    border-left-color: #ffc107;
}

.notification-content {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-content i {
    font-size: 18px;
    color: var(--color-primary);
}

.notification-success .notification-content i {
    color: #28a745;
}

.notification-error .notification-content i {
    color: #dc3545;
}

.notification-warning .notification-content i {
    color: #ffc107;
}

.notification-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
}

.notification-close {
    background: none;
    border: none;
    font-size: 14px;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.notification-close:hover {
    background: #f8f9fa;
    color: #495057;
}

/* Enhanced Form Styling */
.form-field.error input,
.form-field.error select,
.form-field.error textarea {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-field.error .field-label {
    color: #dc3545;
}

/* Save Button Enhanced States */
.action-btn.has-changes {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    animation: pulse-save 2s infinite;
}

@keyframes pulse-save {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Search and Filter */
.search-filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.search-input {
    flex: 1;
    padding: 10px 12px 10px 40px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper::before {
    content: '\f002';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 14px;
    z-index: 1;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(55, 125, 255, 0.1);
}

.filter-dropdown {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    min-width: 120px;
}

.no-results-message {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.no-results-message i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #dee2e6;
}

.no-results-message p {
    font-size: 16px;
    margin: 0;
}

/* Tooltips */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    margin-bottom: 8px;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2c3e50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    margin-bottom: 2px;
}

.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Keyboard Shortcuts Indicator */
.keyboard-shortcuts {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(44, 62, 80, 0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 12px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
}

.keyboard-shortcuts.show {
    opacity: 1;
    visibility: visible;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.shortcut-item:last-child {
    margin-bottom: 0;
}

.shortcut-key {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
}

/* Enhanced mobile responsiveness */
@media (max-width: 600px) {
    .location-card,
    .department-card,
    .license-card,
    .insurance-card {
        padding: 16px;
    }
    
    .location-header,
    .department-header,
    .license-header,
    .insurance-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .department-stats {
        justify-content: flex-start;
        gap: 16px;
    }
    
    .location-actions,
    .department-actions,
    .license-actions,
    .insurance-actions {
        width: 100%;
    }
    
    .location-actions .btn,
    .department-actions .btn,
    .license-actions .btn,
    .insurance-actions .btn {
        flex: 1;
    }
    
    .user-actions {
        flex-direction: column;
        gap: 2px;
    }
    
    .backup-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    .company-overview-card {
        background: linear-gradient(135deg, #1a365d 0%, #2d3748 100%);
    }
    
    .status-card {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .section-card {
        background: #2d3748;
        border-color: #4a5568;
    }
}

/* --- Responsive Design --- */
@media (max-width: 1200px) {
    .company-dashboard-layout {
        grid-template-columns: 300px 1fr;
    }
    
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .backup-status-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .company-dashboard-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .company-sidebar {
        order: 2;
        border-right: none;
        border-top: 1px solid #e1e5e9;
        max-height: 300px;
    }
    
    .company-main {
        order: 1;
    }
    
    .company-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .search-and-filter {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .company-header {
        padding: 16px 20px;
    }
    
    .company-section {
        padding: 20px;
    }
    
    .card-header {
        padding: 20px;
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .card-content {
        padding: 20px;
    }
    
    .backup-actions {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .users-table {
        font-size: 12px;
    }
    
    .users-table th,
    .users-table td {
        padding: 12px 8px;
    }
}

/* Additional responsive styles */
@media (max-width: 480px) {
    .form-grid {
        gap: 16px;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .backup-status-cards {
        gap: 16px;
    }
}

/* --- Print Styles --- */
@media print {
    .company-sidebar,
    .company-header,
    .backup-actions,
    .header-actions {
        display: none !important;
    }
    
    .company-dashboard-layout {
        grid-template-columns: 1fr;
    }
    
    .company-section {
        padding: 0;
    }
    
    .section-card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* --- Accessibility --- */
.btn:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.nav-item:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.nav-item:focus {
    background: rgba(13, 110, 253, 0.1);
}

/* --- High Contrast Mode --- */
@media (prefers-contrast: high) {
    .section-card {
        border: 2px solid #000;
    }
    
    .status-card {
        border: 2px solid #000;
    }
    
    .users-table {
        border: 2px solid #000;
    }
}

@media (max-width: 1200px) {
    #company-tab .company-layout {
        flex-direction: column;
    }
}

/* Loading overlay styles */
.company-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.company-loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 200px;
}

.loading-spinner {
    font-size: 24px;
    color: var(--color-primary, #007bff);
    margin-bottom: 15px;
}

.loading-spinner i {
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Notification styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.notification-success {
    background-color: #28a745;
}

.notification-error {
    background-color: #dc3545;
}

.notification-warning {
    background-color: #ffc107;
    color: #212529;
}

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

/* =========================================================
   COMPANY TAB UI REFRESH (SCOPED OVERRIDES)
   Keeps existing HTML/JS IDs intact while improving scaling.
   ========================================================= */
#company-tab {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding: clamp(8px, 1vw, 14px);
    box-sizing: border-box;
    background:
        radial-gradient(circle at 8% 6%, rgba(62, 119, 199, 0.08), transparent 42%),
        radial-gradient(circle at 92% 10%, rgba(31, 63, 120, 0.06), transparent 36%),
        #f3f6fb;
}

#company-tab .company-dashboard-layout {
    height: 100%;
    min-height: 0;
    grid-template-columns: clamp(280px, 23vw, 360px) minmax(0, 1fr);
    gap: clamp(10px, 1vw, 14px);
    background: transparent;
}

#company-tab .company-sidebar,
#company-tab .company-main {
    min-width: 0;
    min-height: 0;
    border: 1px solid #d7e1ef;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow:
        0 10px 24px rgba(15, 23, 42, 0.06),
        0 2px 6px rgba(15, 23, 42, 0.03);
}

#company-tab .company-sidebar {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    border-right: 1px solid #dfe7f1;
}

#company-tab .sidebar-section {
    border-bottom: 1px solid #edf2f8;
}

#company-tab .sidebar-section:last-child {
    border-bottom: none;
}

#company-tab .sidebar-title {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 14px;
    background: linear-gradient(180deg, #fbfdff 0%, #f4f8fd 100%);
    border-bottom: 1px solid #e6eef7;
    color: #486581;
    font-size: 10px;
    letter-spacing: 0.7px;
}

#company-tab .sidebar-title i {
    color: #2f5ea8;
}

#company-tab .company-overview-card {
    margin: 10px;
    border-radius: 14px;
    padding: 16px 14px;
    text-align: left;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    background:
        radial-gradient(circle at 85% 12%, rgba(255, 255, 255, 0.18), transparent 42%),
        linear-gradient(135deg, #1f3f78 0%, #2f5ea8 55%, #3d74c4 100%);
    box-shadow: 0 8px 20px rgba(31, 63, 120, 0.18);
}

#company-tab .company-overview-card::before {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(8px);
}

#company-tab .company-logo {
    margin: 0;
    position: relative;
    z-index: 1;
}

#company-tab .company-logo img {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 10px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

#company-tab .company-basic-info {
    min-width: 0;
    position: relative;
    z-index: 1;
}

#company-tab .company-basic-info h3 {
    margin: 0 0 4px;
    font-size: 16px;
    line-height: 1.2;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    word-break: break-word;
}

#company-tab .company-basic-info p {
    margin: 0 0 8px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 12px;
}

#company-tab .company-status {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
}

#company-tab .status-badge,
#company-tab .license-status {
    font-size: 10px;
    border-radius: 999px;
    padding: 4px 8px;
    letter-spacing: 0.4px;
}

#company-tab .company-nav {
    padding: 6px;
}

#company-tab .nav-item {
    margin: 0 0 4px;
    border: 1px solid transparent;
    border-radius: 10px;
    border-bottom: none;
    padding: 10px 12px;
    gap: 10px;
}

#company-tab .nav-item:hover {
    background: #f7fbff;
    border-color: #e5eef8;
}

#company-tab .nav-item.active {
    border-right: none;
    border-left: 3px solid #2f5ea8;
    background: linear-gradient(90deg, rgba(47, 94, 168, 0.12) 0%, rgba(47, 94, 168, 0.03) 100%);
    border-color: rgba(47, 94, 168, 0.16);
    color: #1f4f9f;
}

#company-tab .nav-item span {
    min-width: 0;
    line-height: 1.25;
}

#company-tab .quick-stats {
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

#company-tab .stat-item {
    border: 1px solid #e4ecf6;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.03);
    padding: 10px 12px;
}

#company-tab .company-main {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
}

#company-tab .company-header {
    margin: 10px 10px 0;
    border: 1px solid #d6e2f1;
    border-radius: 14px;
    background: linear-gradient(135deg, #1f3f78 0%, #2d548f 55%, #3a6db9 100%);
    box-shadow: 0 8px 20px rgba(31, 63, 120, 0.16);
    padding: 16px 18px;
    align-items: center;
}

#company-tab .header-title-section h2 {
    margin-bottom: 4px;
    font-size: clamp(20px, 1.5vw, 24px);
    line-height: 1.15;
}

#company-tab .header-title-section p {
    color: rgba(255, 255, 255, 0.88);
    font-size: 12px;
    max-width: 64ch;
}

#company-tab .header-actions {
    margin-top: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

#company-tab .header-actions .btn {
    min-height: 38px;
    border-radius: 10px;
    box-shadow: none;
}

#company-tab .company-section {
    padding: 14px 10px 10px;
    overflow: auto;
    scrollbar-gutter: stable both-edges;
}

#company-tab .section-card {
    margin-bottom: 14px;
    border: 1px solid #dbe6f3;
    border-radius: 14px;
    box-shadow:
        0 6px 18px rgba(15, 23, 42, 0.05),
        0 1px 4px rgba(15, 23, 42, 0.03);
}

#company-tab .card-header {
    padding: 16px 18px;
    border-bottom: 1px solid #e7eef7;
    background: linear-gradient(180deg, #fbfdff 0%, #f5f9fd 100%);
}

#company-tab .card-header h3 {
    font-size: 18px;
    margin-bottom: 4px;
    color: #1f334d;
}

#company-tab .card-header p {
    font-size: 12px;
    color: #627d98;
}

#company-tab .card-content {
    padding: 16px 18px;
}

#company-tab .form-grid {
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#company-tab .form-group label {
    margin-bottom: 5px;
    font-size: 11px;
    color: #486581;
    letter-spacing: 0.5px;
}

#company-tab .form-group input,
#company-tab .form-group select,
#company-tab .form-group textarea,
#company-tab .search-input,
#company-tab .filter-dropdown {
    border-color: #cfd9e6;
    border-radius: 9px;
    background: #fff;
    box-shadow: none;
}

#company-tab .form-group input:focus,
#company-tab .form-group select:focus,
#company-tab .form-group textarea:focus,
#company-tab .search-input:focus,
#company-tab .filter-dropdown:focus {
    border-color: #3d74c4;
    box-shadow: 0 0 0 3px rgba(61, 116, 196, 0.12);
}

#company-tab .logo-upload-area {
    border: 1px dashed #bcd0ea;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbfdff 0%, #f5f9ff 100%);
    padding: 14px;
}

#company-tab .logo-preview {
    min-height: 132px;
    margin-bottom: 12px;
    border: 1px dashed #d7e4f3;
    border-radius: 12px;
    background:
        radial-gradient(circle at 15% 15%, rgba(61, 116, 196, 0.07), transparent 42%),
        #ffffff;
    overflow: hidden;
}

#company-tab .logo-preview img {
    max-width: 128px;
    max-height: 128px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e2ebf5;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
    padding: 10px;
}

#company-tab .logo-preview img[src=""],
#company-tab .logo-preview img:not([src]) {
    display: none;
}

#company-tab .logo-preview img[src]:not([src=""]) + .upload-placeholder {
    display: none;
}

#company-tab .upload-placeholder {
    padding: 14px;
    color: #627d98;
}

#company-tab .upload-placeholder i {
    color: #90a9c8;
}

#company-tab .logo-actions {
    flex-wrap: wrap;
    gap: 8px;
}

#company-tab .logo-actions .btn {
    border-radius: 10px;
    min-height: 36px;
}

#company-tab .search-and-filter,
#company-tab .search-filter-bar {
    border: 1px solid #e3ebf5;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbfdff 0%, #f5f9fd 100%);
    padding: 12px;
    gap: 10px;
}

#company-tab .search-input-wrapper {
    min-width: 0;
}

#company-tab .employees-table-container,
#company-tab .users-table-container {
    border: 1px solid #e3ebf5;
    border-radius: 12px;
    overflow: auto;
    background: #fff;
}

#company-tab .employees-table,
#company-tab .users-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

#company-tab .employees-table th,
#company-tab .employees-table td,
#company-tab .users-table th,
#company-tab .users-table td {
    border-bottom: 1px solid #edf2f8;
    padding: 11px 12px;
    vertical-align: middle;
}

#company-tab .employees-table thead th,
#company-tab .users-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(180deg, #f7faff 0%, #eef4fb 100%);
    color: #486581;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#company-tab .employees-table tbody tr:hover,
#company-tab .users-table tbody tr:hover {
    background: #f8fbff;
}

#company-tab .table-actions,
#company-tab .user-actions,
#company-tab .employee-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#company-tab .table-actions .btn,
#company-tab .user-actions .btn,
#company-tab .employee-actions .btn {
    border-radius: 8px;
}

#company-tab .status-card,
#company-tab .backup-status-card,
#company-tab .integration-card {
    border: 1px solid #dbe6f3;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

#company-tab .empty-state {
    color: #627d98;
    font-style: normal;
}

#company-tab .empty-state i {
    color: #90a9c8;
}

#company-tab .modal-content {
    border-radius: 14px;
    border: 1px solid #d7e1ef;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.2);
}

@media (max-width: 1360px) {
    #company-tab .company-dashboard-layout {
        grid-template-columns: clamp(260px, 28vw, 320px) minmax(0, 1fr);
    }

    #company-tab .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #company-tab .form-group.span-3 {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1100px) {
    #company-tab .company-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    #company-tab .header-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 920px) {
    #company-tab .company-dashboard-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    #company-tab .company-sidebar {
        max-height: 320px;
        border-right: 1px solid #dfe7f1;
        border-top: none;
    }

    #company-tab .company-overview-card {
        grid-template-columns: auto minmax(0, 1fr);
    }
}

@media (max-width: 720px) {
    #company-tab {
        padding: 8px;
    }

    #company-tab .company-header {
        margin: 8px 8px 0;
        padding: 12px;
    }

    #company-tab .header-actions {
        width: 100%;
    }

    #company-tab .header-actions .btn {
        flex: 1 1 100%;
    }

    #company-tab .company-section {
        padding: 10px 8px 8px;
    }

    #company-tab .card-header,
    #company-tab .card-content {
        padding: 12px;
    }

    #company-tab .form-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    #company-tab .form-group.span-2,
    #company-tab .form-group.span-3 {
        grid-column: auto;
    }

    #company-tab .search-and-filter,
    #company-tab .search-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    #company-tab .employees-table,
    #company-tab .users-table {
        min-width: 720px;
    }
}

/* Company profile discoverability fields (additive) */
#company-tab .company-form-section-label {
    padding: 8px 10px 2px;
    border: 1px dashed #d7e4f3;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbfdff 0%, #f6faff 100%);
}

#company-tab .company-form-section-label > label {
    margin-bottom: 2px;
}

#company-tab .company-field-help {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.35;
    color: #627d98;
}

#company-tab .company-checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    margin-top: 6px;
}

#company-tab .company-inline-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #dbe6f3;
    border-radius: 10px;
    background: #fbfdff;
    color: #334e68;
    cursor: pointer;
    font-size: 13px;
}

#company-tab .company-inline-checkbox:hover {
    border-color: #bfd3ee;
    background: #f4f9ff;
}

#company-tab .company-inline-checkbox input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    accent-color: #2f5ea8;
}
