/* ========================================
   Contractor Management System - Main CSS
   Professional Construction Industry Theme
   ======================================== */

/* CSS Variables for Theme */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --sidebar-width: 250px;
    --header-height: 60px;
    --border-radius: 8px;
    --box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* Dark Theme Variables */
[data-bs-theme="dark"] {
    --bs-body-bg: #1a1a1a;
    --bs-body-color: #ffffff;
    --bs-primary: #3498db;
    --bs-secondary: #6c757d;
    --light-color: #2c3e50;
    --dark-color: #ecf0f1;
}

/* Global Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    line-height: 1.6;
    margin-top: var(--header-height);
}

/* Header Styles */
.navbar {
    box-shadow: var(--box-shadow);
    z-index: 1030;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    overflow-y: auto;
    transition: var(--transition);
    padding-bottom: 80px; /* Add padding to prevent footer overlap */
}

.sidebar .nav-link {
    color: var(--bs-body-color);
    padding: 0.75rem 1rem;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
}

.sidebar .nav-link:hover {
    background-color: rgba(52, 152, 219, 0.1);
    color: var(--secondary-color);
}

.sidebar .nav-link.active {
    background-color: var(--secondary-color);
    color: white;
    font-weight: 600;
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--primary-color);
}

/* Submenu Styles */
.sidebar .collapse .nav-link {
    padding-left: 2.5rem;
    font-size: 0.9rem;
}

.sidebar .collapse .nav-link:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

/* Main Content */
main {
    margin-left: 0;
    transition: var(--transition);
    min-height: calc(100vh - var(--header-height));
    padding-top: 1rem;
}

/* Adjust main content when sidebar is present */
@media (min-width: 768px) {
    main {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* Footer Styles */
.footer {
    background-color: var(--light-color);
    border-top: 1px solid rgba(0,0,0,0.1);
    margin-top: auto;
    position: relative;
    z-index: 50; /* Lower than sidebar z-index */
}

/* Ensure footer doesn't overlap with sidebar on larger screens */
@media (min-width: 768px) {
    .footer {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* Cards */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

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

.card-header {
    background-color: var(--light-color);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    font-weight: 600;
}

/* Buttons */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #1a252f;
    border-color: #1a252f;
}

.btn-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: #2980b9;
    border-color: #2980b9;
}

/* Forms */
.form-control {
    border-radius: var(--border-radius);
    border: 1px solid #ddd;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
}

/* Tables */
.table {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table thead th {
    background-color: var(--light-color);
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
    color: var(--dark-color);
}

.table tbody tr:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

/* Alerts */
.alert {
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
}

.alert-success {
    background-color: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

.alert-warning {
    background-color: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
    border-left: 4px solid var(--warning-color);
}

.alert-danger {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
    border-left: 4px solid var(--danger-color);
}

.alert-info {
    background-color: rgba(52, 152, 219, 0.1);
    color: var(--secondary-color);
    border-left: 4px solid var(--secondary-color);
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.5em 0.75em;
}

/* Progress Bars */
.progress {
    height: 8px;
    border-radius: 4px;
    background-color: rgba(0,0,0,0.1);
}

.progress-bar {
    border-radius: 4px;
}

/* Dropdowns */
.dropdown-menu {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0.5rem 0;
    z-index: 1050;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    transition: var(--transition);
}

.dropdown-item:hover {
    background-color: rgba(52, 152, 219, 0.1);
    color: var(--secondary-color);
}

/* Form Select Dropdowns - Fix visibility issues */
.form-select {
    z-index: 1;
}

.select2-container {
    z-index: 1050 !important;
}

.select2-dropdown {
    z-index: 1051 !important;
}

.select2-container--open .select2-dropdown {
    z-index: 1051 !important;
}

/* Ensure bulk action dropdowns are properly styled */
.bulk-actions .form-select {
    z-index: 1;
}

.bulk-actions .select2-container {
    z-index: 1052 !important;
}

.bulk-actions .select2-dropdown {
    z-index: 1053 !important;
}

/* Search form dropdowns */
.search-form .form-select {
    z-index: 1;
}

.search-form .select2-container {
    z-index: 1050 !important;
}

.search-form .select2-dropdown {
    z-index: 1051 !important;
}

/* Required field indicators */
.form-label .text-danger {
    color: #dc3545 !important;
    font-weight: bold;
}

/* Form validation styles */
.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

/* Ensure form elements are properly styled */
.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Notification Dropdown */
.notification-dropdown {
    min-width: 300px;
    max-height: 400px;
    overflow-y: auto;
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

/* Breadcrumb */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: var(--secondary-color);
    font-weight: bold;
}

/* Status Indicators */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-active {
    background-color: var(--success-color);
}

.status-inactive {
    background-color: var(--danger-color);
}

.status-pending {
    background-color: var(--warning-color);
}

/* Role Badges */
.role-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

.role-cwe {
    background-color: #8e44ad;
    color: white;
}

.role-ge {
    background-color: #e74c3c;
    color: white;
}

.role-age {
    background-color: #f39c12;
    color: white;
}

.role-je {
    background-color: #3498db;
    color: white;
}

.role-contractor {
    background-color: #27ae60;
    color: white;
}

.role-supervisor {
    background-color: #95a5a6;
    color: white;
}

/* Dashboard Widgets */
.dashboard-widget {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.dashboard-widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.dashboard-widget .widget-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.dashboard-widget .widget-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.dashboard-widget .widget-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Statistics Cards */
.stat-card {
    text-align: center;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    background: white;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-card .stat-label {
    color: var(--bs-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        padding-bottom: 0; /* Remove padding on mobile since sidebar is hidden */
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    main {
        margin-left: 0;
    }
    
    .footer {
        margin-left: 0;
        width: 100%;
    }
    
    .dashboard-widget {
        margin-bottom: 1rem;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    .footer {
        display: none !important;
    }
    
    main {
        margin-left: 0 !important;
        margin-top: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* Accessibility */
.visually-hidden-focusable:focus {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    z-index: 9999 !important;
    background-color: var(--primary-color) !important;
    color: white !important;
    padding: 0.5rem 1rem !important;
    border-radius: var(--border-radius) !important;
    text-decoration: none !important;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Utility Classes */
.text-primary-custom {
    color: var(--primary-color) !important;
}

.bg-primary-custom {
    background-color: var(--primary-color) !important;
}

.border-primary-custom {
    border-color: var(--primary-color) !important;
}

.shadow-custom {
    box-shadow: var(--box-shadow) !important;
}

.rounded-custom {
    border-radius: var(--border-radius) !important;
}

/* Windows 11 Style Notification System */
.notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

.notification {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 16px 20px;
    min-width: 320px;
    max-width: 400px;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.notification.hide {
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--notification-color, #0078d4), var(--notification-color, #0078d4));
    border-radius: 12px 12px 0 0;
}

.notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.notification-title {
    font-weight: 600;
    font-size: 14px;
    color: #323130;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notification-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--notification-color, #0078d4);
    color: white;
    font-size: 12px;
}

.notification-close {
    background: none;
    border: none;
    color: #605e5c;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 16px;
    line-height: 1;
}

.notification-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.notification-body {
    font-size: 13px;
    color: #605e5c;
    line-height: 1.4;
    margin: 0;
}

.notification-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--notification-color, #0078d4);
    border-radius: 0 0 12px 12px;
    transition: width linear;
    opacity: 0.6;
}

/* Notification Types */
.notification.success {
    --notification-color: #107c10;
}

.notification.success .notification-icon {
    background: #107c10;
}

.notification.error {
    --notification-color: #d13438;
}

.notification.error .notification-icon {
    background: #d13438;
}

.notification.warning {
    --notification-color: #ff8c00;
}

.notification.warning .notification-icon {
    background: #ff8c00;
}

.notification.info {
    --notification-color: #0078d4;
}

.notification.info .notification-icon {
    background: #0078d4;
}

/* Dark Theme Support */
[data-bs-theme="dark"] .notification {
    background: rgba(32, 32, 32, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

[data-bs-theme="dark"] .notification-title {
    color: #ffffff;
}

[data-bs-theme="dark"] .notification-body {
    color: #c8c6c4;
}

[data-bs-theme="dark"] .notification-close {
    color: #c8c6c4;
}

[data-bs-theme="dark"] .notification-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes fadeInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .notification-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .notification {
        min-width: auto;
        max-width: none;
    }
}

/* Construction Industry Specific Styles */
.construction-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.safety-alert {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-left: 4px solid var(--warning-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.safety-alert .alert-icon {
    color: var(--warning-color);
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

/* Project Status Indicators */
.project-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.project-status.planning {
    background-color: #e3f2fd;
    color: #1976d2;
}

.project-status.active {
    background-color: #e8f5e8;
    color: #2e7d32;
}

.project-status.on-hold {
    background-color: #fff3e0;
    color: #f57c00;
}

.project-status.completed {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.project-status.cancelled {
    background-color: #ffebee;
    color: #c62828;
}
