/* CAFM Enterprise - Stylesheet
 * Based on existing design system with enterprise enhancements
 */

/* Modern CSS Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Custom Properties (Variables) */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --accent: #f59e0b;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;
    --success: #10b981;
    --info: #3b82f6;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-500);

    --bg-primary: #ffffff;
    --bg-secondary: var(--gray-50);
    --bg-tertiary: var(--gray-100);

    --border-color: var(--gray-200);
    --border-color-focus: var(--primary);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    --transition: all 0.15s ease-in-out;
    --transition-slow: all 0.3s ease-in-out;
}

/* Base Styles */
html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header - Enhanced for branding */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem 0;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1001;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%23ffffff" fill-opacity="0.05"><circle cx="30" cy="30" r="1"/></g></svg>') repeat;
    opacity: 0.3;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1001;
}

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

.header-logo {
    max-height: 50px;
    width: auto;
}

.header-text h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-tagline {
    font-size: 0.875rem;
    opacity: 0.9;
}

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

.user-name {
    font-weight: 500;
}

.org-switch {
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

.org-switch:hover {
    background: rgba(255,255,255,0.3);
}

/* Navigation */
.nav {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav .container {
    padding: 0 1rem;
}

.nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 0;
    padding: 0;
}

.nav li {
    position: relative;
}

.nav li.nav-right {
    margin-left: auto;
}

.nav a {
    display: block;
    color: var(--text-primary);
    text-decoration: none;
    padding: 1rem 1.25rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    position: relative;
    border-bottom: 3px solid transparent;
}

.nav a:hover {
    color: var(--primary);
    background: var(--gray-50);
}

.nav a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--gray-50);
}

/* Main Content */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* Cards */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h2, .card h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
    position: relative;
    padding-bottom: 0.75rem;
}

.card h2::after, .card h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 3rem;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: var(--radius);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-success { background: var(--success); }
.btn-success:hover { background: var(--secondary-dark); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); }

.btn-warning { background: var(--warning); color: var(--gray-900); }

.btn-secondary { background: var(--gray-600); }
.btn-secondary:hover { background: var(--gray-700); }

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

.btn-large {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table th, .table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Statistics Cards */
.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card h3 {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.stat-card h3::after { display: none; }

.stat-card p {
    opacity: 0.9;
    font-weight: 500;
    font-size: 0.875rem;
}

.stat-card.success { background: linear-gradient(135deg, var(--success) 0%, var(--secondary-dark) 100%); }
.stat-card.warning { background: linear-gradient(135deg, var(--warning) 0%, #f97316 100%); }
.stat-card.danger { background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%); }
.stat-card.info { background: linear-gradient(135deg, var(--info) 0%, #1d4ed8 100%); }

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
}

.alert-close:hover { opacity: 1; }

.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fed7aa; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* Status & Priority Badges */
.status-badge, .priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.priority-critical { color: #7c2d12; background: #fff7ed; border: 1px solid #fed7aa; }
.priority-high { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }
.priority-medium { color: #92400e; background: #fffbeb; border: 1px solid #fed7aa; }
.priority-low { color: #065f46; background: #ecfdf5; border: 1px solid #a7f3d0; }

.status-draft { color: #6b7280; background: #f3f4f6; border: 1px solid #d1d5db; }
.status-pending { color: #92400e; background: #fffbeb; border: 1px solid #fed7aa; }
.status-assigned { color: #1e40af; background: #eff6ff; border: 1px solid #bfdbfe; }
.status-in_progress { color: #1e40af; background: #eff6ff; border: 1px solid #bfdbfe; }
.status-on_hold { color: #92400e; background: #fffbeb; border: 1px solid #fed7aa; }
.status-completed { color: #065f46; background: #ecfdf5; border: 1px solid #a7f3d0; }
.status-cancelled { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }

/* Login Form */
.login-form {
    max-width: 420px;
    margin: 4rem auto;
    padding: 2.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

.login-form h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-size: 1.75rem;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    background: var(--gray-800);
    color: var(--gray-400);
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.875rem;
    margin-top: 2rem;
}

/* Pagination */
.pagination {
    margin: 2rem 0;
}

.pagination-list {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

.pagination-link:hover {
    background: var(--gray-100);
    border-color: var(--primary);
}

.pagination-current {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.pagination-link.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    /* Prevent horizontal scrolling */
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .container {
        padding: 0 1rem;
        max-width: 100%;
        overflow-x: hidden;
    }
    .header-container { flex-direction: column; gap: 1rem; text-align: center; }
    .header-text h1 { font-size: 1.5rem; }
    .nav ul { justify-content: center; }
    .nav a { padding: 0.75rem 1rem; font-size: 0.8rem; }
    .grid { grid-template-columns: 1fr; }
    .card {
        padding: 1.25rem;
        max-width: 100%;
        overflow-x: hidden;
    }
    .stat-card h3 { font-size: 2rem; }
    .login-form { margin: 2rem 1rem; padding: 2rem; }
    .table th, .table td { padding: 0.75rem 0.5rem; font-size: 0.875rem; }

    /* Fix flex layouts causing overflow */
    [style*="display: flex"] {
        flex-wrap: wrap;
    }

    /* Ensure inputs don't overflow */
    input, select, textarea {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .btn { width: 100%; margin-bottom: 0.5rem; }
    .btn-small { width: auto; margin-bottom: 0; }
}
