/* ============================================
   Global Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #f0f2f6;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    padding-top: 0;
    margin: 0;
}

.main-content {
    min-height: calc(100vh - 65px);
}

/* ============================================
   Topbar Styles
   ============================================ */
.topbar {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1050;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar .container-fluid {
    padding: 0 1.5rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    padding: 0.75rem 0;
    color: #2d3748;
    font-weight: 700;
    font-size: 1.1rem;
}

.topbar-brand:hover {
    color: #667eea;
}

.topbar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
}

.topbar-nav .nav-link {
    color: #4a5568;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.9rem;
    position: relative;
}

.topbar-nav .nav-link:hover {
    background: #f7fafc;
    color: #667eea;
}

.topbar-nav .nav-link.active {
    background: #ebf4ff;
    color: #667eea;
}

.topbar-nav .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: #667eea;
    border-radius: 3px 3px 0 0;
}

.topbar-nav .nav-link i {
    margin-right: 6px;
}

/* ============================================
   User Dropdown
   ============================================ */
.user-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.4rem 0.8rem 0.4rem 0.4rem;
    border-radius: 50px;
    border: 2px solid transparent;
    background: transparent;
    color: #2d3748;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.user-dropdown .dropdown-toggle:hover {
    background: #f7fafc;
    border-color: #e2e8f0;
}

.user-dropdown .dropdown-toggle::after {
    display: none;
}

.user-dropdown .dropdown-toggle .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-dropdown .dropdown-toggle .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-dropdown .dropdown-toggle .user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.user-dropdown .dropdown-toggle .user-info .name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #2d3748;
}

.user-dropdown .dropdown-toggle .user-info .email {
    font-size: 0.75rem;
    color: #a0aec0;
}

.user-dropdown .dropdown-toggle .chevron {
    color: #a0aec0;
    font-size: 0.8rem;
    transition: transform 0.3s;
    margin-left: 4px;
}

.user-dropdown .dropdown-toggle.show .chevron {
    transform: rotate(180deg);
}

.user-dropdown .dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 0.5rem;
    min-width: 220px;
    margin-top: 8px;
}

.user-dropdown .dropdown-menu .dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f2f6;
    margin-bottom: 0.5rem;
}

.user-dropdown .dropdown-menu .dropdown-header .header-name {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.95rem;
}

.user-dropdown .dropdown-menu .dropdown-header .header-email {
    font-size: 0.8rem;
    color: #a0aec0;
}

.user-dropdown .dropdown-menu .dropdown-item {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    color: #4a5568;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.user-dropdown .dropdown-menu .dropdown-item:hover {
    background: #f7fafc;
    color: #667eea;
}

.user-dropdown .dropdown-menu .dropdown-item i {
    width: 18px;
    font-size: 1rem;
    color: #a0aec0;
}

.user-dropdown .dropdown-menu .dropdown-item:hover i {
    color: #667eea;
}

.user-dropdown .dropdown-menu .dropdown-item.text-danger:hover {
    background: #fff5f5;
    color: #fc8181;
}

.user-dropdown .dropdown-menu .dropdown-item.text-danger:hover i {
    color: #fc8181;
}

.user-dropdown .dropdown-menu .dropdown-divider {
    margin: 0.5rem 0;
    border-color: #f0f2f6;
}

/* ============================================
   Card & Dashboard Styles
   ============================================ */
.dashboard-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    background: white;
}

.dashboard-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* ============================================
   Stat Cards
   ============================================ */
.stat-card {
    background: white;
    border: none;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.3s, box-shadow 0.3s;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: #2d3748;
}

.stat-card .stat-label {
    color: #718096;
    margin: 0;
    font-weight: 500;
    font-size: 0.9rem;
}

.stat-card .stat-change {
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-card .stat-change.positive { color: #48bb78; }
.stat-card .stat-change.negative { color: #fc8181; }

/* Stat Icon Colors */
.stat-icon-purple { background: #e9d8fd; color: #6b46c1; }
.stat-icon-blue { background: #bee3f8; color: #2b6cb0; }
.stat-icon-green { background: #c6f6d5; color: #276749; }
.stat-icon-orange { background: #feebc8; color: #c05621; }
.stat-icon-red { background: #fed7d7; color: #c53030; }
.stat-icon-teal { background: #b2f5ea; color: #234e52; }
.stat-icon-pink { background: #fbb6ce; color: #702459; }
.stat-icon-indigo { background: #c3dafe; color: #3730a3; }

/* Gradient Stat Cards */
.stat-card-gradient {
    color: white;
    border: none;
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform 0.3s;
}

.stat-card-gradient:hover {
    transform: translateY(-3px);
}

.stat-card-gradient .stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    color: white;
    line-height: 1.2;
}

.stat-card-gradient .stat-label {
    opacity: 0.9;
    margin: 0;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
    color: white;
}

.stat-card-purple-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-card-green-gradient {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.stat-card-blue-gradient {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-card-orange-gradient {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* ============================================
   Table Styles
   ============================================ */
.table-container {
    border-radius: 12px;
    overflow: hidden;
}

.table-container table {
    margin-bottom: 0;
}

.table-container thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    color: #4a5568;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem;
    white-space: nowrap;
}

.table-container tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f2f6;
}

.table-container tbody tr {
    transition: background 0.2s;
}

.table-container tbody tr:hover {
    background: #f7fafc;
}

.table-container tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   Badges
   ============================================ */
.badge-status {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active { background: #c6f6d5; color: #276749; }
.badge-inactive { background: #fed7d7; color: #c53030; }
.badge-deployed { background: #c6f6d5; color: #276749; }
.badge-draft { background: #feebc8; color: #c05621; }
.badge-archived { background: #e2e8f0; color: #4a5568; }
.badge-secondary { background: #e2e8f0; color: #4a5568; }

.badge-role {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.badge-superuser { background: #e9d8fd; color: #6b46c1; }
.badge-admin { background: #bee3f8; color: #2b6cb0; }
.badge-user { background: #f0f2f6; color: #4a5568; }
.badge-viewer { background: #feebc8; color: #c05621; }

/* ============================================
   Search & Filters
   ============================================ */
.search-wrapper {
    position: relative;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #a0aec0;
}

.search-wrapper .form-control {
    padding-left: 2.5rem;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s;
}

.search-wrapper .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-select {
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.filter-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ============================================
   Quick Stats
   ============================================ */
.quick-stats {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quick-stat {
    background: #f8fafc;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #4a5568;
}

.quick-stat strong {
    color: #2d3748;
}

/* ============================================
   Pagination
   ============================================ */
.pagination .page-link {
    color: #667eea;
    border-radius: 8px;
    margin: 0 2px;
    border: none;
    padding: 0.5rem 0.75rem;
}

.pagination .page-item.active .page-link {
    background: #667eea;
    color: white;
}

.pagination .page-item.disabled .page-link {
    color: #cbd5e0;
}

.pagination .page-link:hover:not(.active) {
    background: #f7fafc;
    color: #667eea;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #a0aec0;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ============================================
   Modals
   ============================================ */
.modal-content {
    border-radius: 16px;
    border: none;
}

.modal-header {
    border-bottom: 2px solid #f0f2f6;
    padding: 1.25rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 2px solid #f0f2f6;
    padding: 1.25rem 1.5rem;
}

.modal-detail-table {
    margin-bottom: 0;
}

.modal-detail-table th {
    width: 140px;
    font-weight: 600;
    color: #4a5568;
    background: #f8fafc;
    padding: 0.75rem 1rem;
}

.modal-detail-table td {
    padding: 0.75rem 1rem;
    color: #2d3748;
}

/* ============================================
   Buttons
   ============================================ */
.btn-download {
    padding: 0.75rem 2rem;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.view-submissions-btn {
    padding: 0.75rem 2.5rem;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
}

.view-submissions-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1.25rem;
    border-radius: 10px;
    background: white;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    text-decoration: none;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #f8fafc;
    border-color: #667eea;
    color: #667eea;
    transform: translateX(-3px);
}

/* ============================================
   User Specific Styles
   ============================================ */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    color: #2d3748;
}

.user-email {
    font-size: 0.85rem;
    color: #a0aec0;
}

.user-actions .btn {
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.user-actions .btn:hover {
    transform: scale(1.1);
}

/* ============================================
   Asset Specific Styles
   ============================================ */
.asset-name {
    font-weight: 600;
    color: #2d3748;
}

.asset-name small {
    display: block;
    font-weight: 400;
    color: #a0aec0;
    font-size: 0.8rem;
}

.submission-count {
    font-weight: 600;
    color: #2d3748;
}

.submission-count .total {
    color: #718096;
    font-weight: 400;
}

.action-buttons .btn {
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.action-buttons .btn:hover {
    transform: scale(1.1);
}

/* ============================================
   Profile Specific Styles
   ============================================ */
.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    font-weight: 600;
    margin: 0 auto 1rem;
    border: 4px solid white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-header {
    text-align: center;
    padding: 2rem 2rem 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 16px 16px 0 0;
}

.profile-header .role-badge {
    background: #667eea;
    color: white;
    padding: 0.25rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.profile-stat {
    text-align: center;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 12px;
    transition: transform 0.2s;
}

.profile-stat:hover {
    transform: translateY(-2px);
}

.profile-stat .stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
}

.profile-stat .stat-label {
    font-size: 0.8rem;
    color: #a0aec0;
    margin-top: 0.25rem;
}

.profile-details {
    padding: 1.5rem 2rem 2rem;
}

.profile-details .detail-row {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f2f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profile-details .detail-row:last-child {
    border-bottom: none;
}

.profile-details .detail-label {
    font-weight: 600;
    color: #4a5568;
}

.profile-details .detail-value {
    color: #2d3748;
}

.btn-edit-profile {
    border-radius: 10px;
    padding: 0.6rem 2rem;
    font-weight: 500;
}

/* ============================================
   Submission Specific Styles
   ============================================ */
.submission-table {
    font-size: 0.9rem;
}

.submission-table thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    color: #4a5568;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    padding: 0.75rem 1rem;
}

.submission-table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.submission-table .row-number {
    color: #a0aec0;
    font-weight: 500;
    text-align: center;
}

.badge-field {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    background: #e2e8f0;
    color: #4a5568;
    border-radius: 4px;
}

.field-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.field-selector .form-check {
    margin-right: 0.5rem;
}

.field-selector .form-check-label {
    font-size: 0.85rem;
    color: #4a5568;
}

/* ============================================
   Submission Detail Modal
   ============================================ */
.submission-detail-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.submission-detail-modal .detail-row {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f2f6;
}

.submission-detail-modal .detail-label {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
}

.submission-detail-modal .detail-value {
    color: #2d3748;
    word-break: break-word;
}

.submission-detail-modal .detail-value pre {
    background: #f8fafc;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin: 0;
}



/* Device ID Badge */
.device-id-badge {
    font-family: 'Courier New', monospace;
    background: #e2e8f0;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    display: inline-block;
}

.user-type-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.modal-lg-custom {
    max-width: 800px;
}

.form-section-title {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

/* Form styling */
.form-label {
    font-weight: 500;
    color: #4a5568;
    font-size: 0.9rem;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s;
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* User actions in table */
.user-actions .btn {
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.user-actions .btn:hover {
    transform: scale(1.1);
}

.user-actions .btn-outline-danger:hover {
    background: #fed7d7;
    border-color: #fc8181;
}

.user-actions .btn-outline-success:hover {
    background: #c6f6d5;
    border-color: #48bb78;
}

/* Local user badge */
.badge-local {
    background: #bee3f8;
    color: #2b6cb0;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
}



/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 991px) {
    .topbar .container-fluid {
        padding: 0 1rem;
    }
    
    .topbar-nav .nav-link span {
        display: none;
    }
    
    .topbar-nav .nav-link i {
        margin-right: 0;
        font-size: 1.2rem;
    }
    
    .user-dropdown .dropdown-toggle .user-info {
        display: none;
    }
    
    .topbar-brand span {
        display: none;
    }
}

@media (max-width: 768px) {
    .stat-card .stat-number {
        font-size: 1.5rem;
    }
    
    .table-container {
        font-size: 0.9rem;
    }
    
    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .profile-details .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

@media (max-width: 576px) {
    .topbar-nav .nav-link {
        padding: 0.4rem 0.6rem;
    }
    
    .user-dropdown .dropdown-toggle {
        padding: 0.2rem;
    }
    
    .user-dropdown .dropdown-toggle .chevron {
        display: none;
    }
    
    .profile-stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .profile-stat {
        padding: 0.75rem;
    }
    
    .profile-stat .stat-number {
        font-size: 1.2rem;
    }
    
    .modal-detail-table th {
        width: 100px;
        font-size: 0.85rem;
    }
}