/**
 * RISE Maintenance Manager - Main Styles
 */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.6;
}

/* Home Page */
.home-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    padding: 24px;
}
.home-container { width: 100%; max-width: 540px; text-align: center; }
.home-content {
    background: #fff;
    border-radius: 20px;
    padding: 48px 44px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
}
.home-logo { max-width: 150px; height: auto; margin-bottom: 24px; }
.home-title { font-size: 1.85rem; font-weight: 700; color: #1a1a2e; margin-bottom: 8px; }
.home-tagline { font-size: 1rem; color: #6366f1; font-weight: 600; margin-bottom: 16px; }
.home-description { font-size: 0.95rem; color: #64748b; line-height: 1.7; margin-bottom: 28px; }
.btn-lg {
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border-radius: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-lg:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -5px rgba(99,102,241,0.4); color: #fff; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    padding: 24px;
}
.login-back { color: rgba(255,255,255,0.9); text-decoration: none; align-self: flex-start; margin-bottom: 20px; font-size: 0.9rem; }
.login-back:hover { color: #fff; }
.login-container { width: 100%; max-width: 420px; }
.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
    padding: 40px;
}
.login-card .logo { text-align: center; margin-bottom: 28px; }
.login-logo-img { max-width: 120px; height: auto; margin-bottom: 16px; display: block; margin-left: auto; margin-right: auto; }
.login-card .logo h1 { color: #6366f1; font-size: 1.5rem; }
.login-card .logo p { color: #64748b; font-size: 0.875rem; margin-top: 4px; }
.header-logo-link { display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; }
.header-logo-img { height: 36px; width: auto; }
.header-logo-text { font-size: 20px; font-weight: 700; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 14px; }
.form-group input { width: 100%; padding: 12px 15px; border: 2px solid #e0e0e0; border-radius: 6px; font-size: 15px; }
.form-group input {
    transition: border-color 0.2s;
}
.form-group input:focus { outline: none; border-color: #6366f1; }
.form-group textarea { width: 100%; padding: 12px 15px; border: 2px solid #e0e0e0; border-radius: 6px; font-size: 15px; font-family: inherit; }
.form-group textarea:focus { outline: none; border-color: #6366f1; }
.form-group select { width: 100%; padding: 12px 15px; border: 2px solid #e0e0e0; border-radius: 6px; font-size: 15px; background: white; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.btn-secondary { background: #64748b; color: white; text-decoration: none; display: inline-block; }
.btn-danger { background: #dc2626; color: white; }
.error { color: #dc2626; margin-bottom: 16px; }
.sla-timer { font-size: 12px; font-weight: 600; }
.sla-ok { color: #16a34a; }
.sla-warning { color: #ea580c; }
.sla-breach { color: #dc2626; }
.site-card, .contractor-card, .user-card { margin-bottom: 12px; }
.pagination { display: flex; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.pagination a { color: #6366f1; text-decoration: none; }
.pagination a:hover { text-decoration: underline; }
.alert { padding: 12px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; }
.alert-error { background: #fee; color: #c33; border: 1px solid #fcc; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.btn { padding: 12px 24px; border: none; border-radius: 6px; font-size: 16px; font-weight: 600; cursor: pointer; transition: transform 0.2s; }
.btn-primary { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); color: white; }
.btn-block { width: 100%; }
.btn:hover { transform: translateY(-1px); }
.login-footer { text-align: center; margin-top: 20px; font-size: 13px; color: #888; }

/* Header */
.admin-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-content { display: flex; justify-content: space-between; align-items: center; max-width: 1600px; margin: 0 auto; }
.header-logo a { color: white; text-decoration: none; font-size: 20px; font-weight: 700; }
.mobile-menu-wrapper { display: flex; align-items: center; gap: 10px; }
.sidebar-toggle { background: none; border: none; color: white; font-size: 24px; cursor: pointer; padding: 5px 10px; }
.header-right { display: flex; align-items: center; gap: 20px; }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-badge { background: rgba(255,255,255,0.2); padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.logout-btn { background: rgba(255,255,255,0.15); color: white; padding: 8px 16px; border-radius: 6px; text-decoration: none; transition: background 0.3s; }
.logout-btn:hover { background: rgba(255,255,255,0.25); }

/* Container & Sidebar */
.admin-container { display: flex; max-width: 1600px; margin: 0 auto; min-height: calc(100vh - 60px); }
.admin-sidebar { width: 250px; background: white; box-shadow: 2px 0 10px rgba(0,0,0,0.05); padding: 20px 0; flex-shrink: 0; }
.sidebar-nav { display: flex; flex-direction: column; min-height: calc(100vh - 60px - 40px); }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 15px 25px; color: #333; text-decoration: none; transition: all 0.3s; border-left: 3px solid transparent; }
.nav-item:hover { background: #f1f5f9; border-left-color: #6366f1; }
.nav-item-logout { margin-top: auto; border-top: 1px solid #eee; color: #666; }
.nav-item-logout:hover { background: #fff5f5; border-left-color: #c00; }
.nav-icon { font-size: 20px; width: 24px; text-align: center; }
.nav-text { font-size: 15px; flex: 1; }

/* Main Content */
.main-content { flex: 1; padding: 30px; overflow-x: hidden; }
.main-content h1 { color: #333; margin-bottom: 10px; font-size: 28px; }
.muted { color: #666; margin-bottom: 25px; font-size: 15px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; border-radius: 10px; padding: 25px; display: flex; align-items: center; gap: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); transition: transform 0.3s; }
.stat-card:hover { transform: translateY(-3px); }
.stat-card.pending { border-left: 4px solid #ffa726; }
.stat-card.completed { border-left: 4px solid #66bb6a; }
.stat-card.users { border-left: 4px solid #42a5f5; }
.stat-icon { font-size: 32px; color: #6366f1; }
.stat-info h3 { font-size: 28px; color: #333; margin-bottom: 5px; }
.stat-info p { color: #666; font-size: 14px; }

/* Cards */
.card { background: white; border-radius: 10px; padding: 25px; margin-bottom: 25px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.card h2 { font-size: 20px; margin-bottom: 20px; color: #333; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 25px; }
.job-row, .company-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #eee; }
.job-row:last-child, .company-row:last-child { border-bottom: none; }
.job-row a, .company-row a { color: #333; text-decoration: none; }
.job-row a:hover, .company-row a:hover { color: #6366f1; }
.empty-state { color: #999; padding: 20px; text-align: center; }

/* Badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-new { background: #e3f2fd; color: #1565c0; }
.badge-assigned { background: #fff3e0; color: #e65100; }
.badge-in_progress { background: #e8f5e9; color: #2e7d32; }
.badge-completed, .badge-closed { background: #e8f5e9; color: #2e7d32; }
.badge-pending_parts, .badge-pending_review { background: #fff8e1; color: #f57f17; }
.badge-cancelled { background: #ffebee; color: #c62828; }
.badge-emergency { background: #ffebee; color: #c62828; }
.badge-urgent { background: #fff3e0; color: #e65100; }
.badge-standard { background: #e3f2fd; color: #1565c0; }
.badge-low { background: #f5f5f5; color: #616161; }
.badge-muted { background: #e0e0e0; color: #616161; font-size: 11px; }

/* Job Card */
.job-card { background: white; border-radius: 8px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.job-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.job-card-title { font-weight: 600; color: #333; text-decoration: none; }
.job-card-title:hover { color: #667eea; }
.job-card-meta { font-size: 13px; color: #666; margin-bottom: 10px; }
.job-card-meta span { margin-right: 15px; }
.job-card-footer { padding-top: 10px; border-top: 1px solid #eee; }

/* Quick Links */
.quick-links { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 25px; }
.quick-link-btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); color: white; text-decoration: none; border-radius: 10px; font-weight: 600; font-size: 0.875rem; transition: transform 0.2s, box-shadow 0.2s; }
.quick-link-btn:hover { transform: translateY(-2px); color: white; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #eee; }
.data-table th { background: #f8f9fa; font-weight: 600; color: #333; }
.data-table a { color: #6366f1; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.job-detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; }

/* Chat widget */
.chat-widget { border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; }
.chat-messages { max-height: 300px; overflow-y: auto; padding: 16px; }
.chat-message { margin-bottom: 12px; }
.chat-message.own { text-align: right; }
.chat-bubble { display: inline-block; max-width: 80%; padding: 10px 14px; border-radius: 12px; background: #f1f5f9; text-align: left; }
.chat-bubble-internal { background: #f5f5f5; border-left: 3px solid #999; }
.chat-message.own .chat-bubble { background: #6366f1; color: white; }
.chat-message.own .chat-bubble-internal { background: #e8e8e8; color: #333; border-left-color: #666; }
.chat-sender { font-size: 12px; color: #666; display: block; margin-bottom: 4px; }
.chat-time { font-size: 11px; color: #999; display: block; margin-top: 4px; }
.chat-form { display: flex; gap: 10px; padding: 16px; border-top: 1px solid #eee; }
.chat-form textarea { flex: 1; resize: none; }

/* File upload */
.file-upload-component { margin-bottom: 16px; }
.file-upload-label { display: block; margin-bottom: 8px; font-weight: 500; }
.file-upload-hint { font-size: 12px; color: #666; margin-top: 6px; }

/* Chart widget */
.chart-table { width: 100%; }
.chart-label { padding: 8px 0; width: 40%; }
.chart-bar-cell { padding: 8px 0; position: relative; }
.chart-bar { height: 20px; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 4px; min-width: 20px; }
.chart-value { margin-left: 10px; font-weight: 600; }

/* Toast notifications */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 14px 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); opacity: 0; transform: translateX(100%); transition: opacity 0.3s, transform 0.3s; max-width: 320px; }
.toast-show { opacity: 1; transform: translateX(0); }
.toast-success { background: #10b981; color: white; }
.toast-error { background: #ef4444; color: white; }
.toast-info { background: #3b82f6; color: white; }

/* Footer */
.admin-footer { text-align: center; padding: 20px; color: #666; font-size: 13px; border-top: 1px solid #eee; margin-top: auto; }

/* Utility */
.btn-link { background: none; border: none; cursor: pointer; font-size: inherit; padding: 0; text-decoration: underline; }
.text-danger { color: #c00; }
.btn-link.text-danger:hover { color: #a00; }

/* Responsive */
@media (max-width: 768px) {
    .admin-sidebar { position: fixed; left: -250px; top: 60px; bottom: 0; z-index: 999; transition: left 0.3s; }
    .admin-sidebar.active { left: 0; }
    .main-content { padding: 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
