/* style.css - SaaS Design System & Styling (MaintainX-style Glassmorphism) */

:root {
    /* Light Theme Palette */
    --bg-main: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.75);
    --bg-card-solid: #ffffff;
    --border: rgba(226, 232, 240, 0.8);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    
    /* Global Accents */
    --primary: #005685;
    --primary-light: #e0f2fe;
    --primary-hover: #004469;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #0ea5e9;
    
    /* Layout Sizes */
    --header-height: 70px;
    --sidebar-width: 260px;
    --blur: blur(12px);
}

/* Dark Theme Palette overrides */
.dark-theme {
    --bg-main: #0b0f19;
    --bg-card: rgba(21, 28, 44, 0.75);
    --bg-card-solid: #151c2c;
    --border: rgba(31, 41, 55, 0.6);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    
    --primary: #38bdf8;
    --primary-light: #0369a1;
    --primary-hover: #7dd3fc;
}

/* Reset and Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Scrollbar customizations */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Header Navbar Styles */
.cws-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: var(--shadow);
    transition: background-color 0.3s, border-color 0.3s;
}

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

.cws-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.03em;
}

.cws-logo span {
    color: var(--info);
}

.role-pill {
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    letter-spacing: 0.05em;
    border: 1px solid var(--border);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background-color: var(--border);
    color: var(--text-main);
}

.sun-icon { display: block; }
.moon-icon { display: none; }
.dark-theme .sun-icon { display: none; }
.dark-theme .moon-icon { display: block; }

/* Icon badge container */
.icon-badge-container {
    position: relative;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-badge-container:hover {
    background-color: var(--border);
    color: var(--text-main);
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 9999px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-card-solid);
}

.badge-red {
    background-color: var(--danger);
}

/* Notifications Dropdown */
.notif-dropdown {
    position: absolute;
    top: 45px;
    right: 0;
    width: 320px;
    background-color: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    cursor: default;
}

.notif-dropdown.show {
    display: flex;
}

.notif-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
}

.notif-dropdown-header a {
    font-size: 0.75rem;
    color: var(--primary);
    text-decoration: none;
}

.notif-dropdown-header a:hover {
    text-decoration: underline;
}

.notif-dropdown-list {
    max-height: 250px;
    overflow-y: auto;
}

.notif-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    transition: background-color 0.2s;
}

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

.notif-item.unread {
    background-color: rgba(0, 86, 133, 0.05);
    border-left: 3px solid var(--primary);
}

.notif-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.dark-theme .notif-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.notif-message {
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.notif-time {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.notif-item-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.logout-btn:hover {
    background-color: var(--danger);
    color: white;
}

/* App Container Layout */
.app-container {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    transition: background-color 0.3s, border-color 0.3s;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.925rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.sidebar-item i {
    font-size: 1rem;
}

.sidebar-item:hover {
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.02);
}

.dark-theme .sidebar-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.sidebar-item.active {
    color: var(--primary);
    background-color: rgba(0, 86, 133, 0.06);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-divider {
    height: 1px;
    background-color: var(--border);
    margin: 1rem 0;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.075em;
    color: var(--text-muted);
    padding: 0 1.5rem 0.5rem 1.5rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.powered-by {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.powered-by strong {
    color: var(--primary);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    max-width: calc(100% - var(--sidebar-width));
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .content-area {
        max-width: 100%;
        padding: 1.25rem;
    }
    .logout-btn span {
        display: none;
    }
}

/* Page Header & Common Components */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title-block h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.03em;
}

.page-title-block p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs i {
    font-size: 0.75rem;
}

/* Cards & Layout Grid */
.cws-card {
    background-color: var(--bg-card);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: background-color 0.3s, border-color 0.3s, transform 0.2s;
}

.cws-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
}

.cws-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-1 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-cols-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) {
    .grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* KPI Cards Styles */
.kpi-card {
    border-radius: 14px;
    padding: 1.5rem;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.kpi-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 800;
    margin-top: 1rem;
    letter-spacing: -0.03em;
}

.kpi-subtitle {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0.75;
}

.bg-gradient-navy {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.bg-gradient-blue {
    background: linear-gradient(135deg, #005685 0%, #0284c7 100%);
}

.bg-gradient-green {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.bg-gradient-orange {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: 1px solid transparent;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-card-solid);
    border-color: var(--border);
    color: var(--text-main);
}

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

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

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

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

.form-control {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-card-solid);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    box-sizing: border-box;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 86, 133, 0.12);
}

.form-control:disabled, .form-control[readonly] {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
    cursor: not-allowed;
}

.dark-theme .form-control:disabled, .dark-theme .form-control[readonly] {
    background-color: rgba(255, 255, 255, 0.05);
}

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

/* Dynamic parts builder */
.parts-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-low {
    background-color: #f1f5f9;
    color: #475569;
}

.badge-medium {
    background-color: rgba(14, 165, 233, 0.15);
    color: #0284c7;
}

.dark-theme .badge-medium {
    background-color: rgba(14, 165, 233, 0.25);
}

.badge-high {
    background-color: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.badge-urgent {
    background-color: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

/* Ticket States badges */
.badge-pending {
    background-color: rgba(100, 116, 139, 0.15);
    color: #64748b;
}

.badge-completed {
    background-color: rgba(16, 185, 129, 0.15);
    color: #059669;
}

/* Technician Work Order colors: Red, Yellow, Green */
.badge-wo-pending {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444; /* Red */
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-wo-dispatched {
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b; /* Yellow */
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-wo-completed {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981; /* Green */
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Tables style */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.cws-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

.cws-table th {
    background-color: rgba(0, 0, 0, 0.02);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.875rem 1rem;
    border-bottom: 2px solid var(--border);
}

.dark-theme .cws-table th {
    background-color: rgba(255, 255, 255, 0.02);
}

.cws-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text-main);
}

.cws-table tr:hover td {
    background-color: rgba(0, 0, 0, 0.01);
}

.dark-theme .cws-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.01);
}

/* Photo Upload Preview Styling */
.image-preview-box {
    width: 120px;
    height: 120px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background-color: rgba(0, 0, 0, 0.02);
}

.dark-theme .image-preview-box {
    background-color: rgba(255, 255, 255, 0.02);
}

.image-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-box span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem;
}

/* Dynamic comments/internal logs */
.comments-log {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.comment-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    max-width: 85%;
}

.comment-bubble.manager {
    background-color: var(--border);
    color: var(--text-main);
    align-self: flex-start;
}

.comment-bubble.internal {
    background-color: var(--warning-light);
    color: #92400e;
    align-self: flex-start;
    border: 1px solid #fde68a;
}

.comment-bubble.technician {
    background-color: var(--primary-light);
    color: var(--primary);
    align-self: flex-end;
}

.comment-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: right;
}

/* Live Timer Console */
.timer-console {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 1.5rem;
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.dark-theme .timer-console {
    background-color: rgba(255, 255, 255, 0.02);
}

.timer-clock {
    font-family: monospace;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

/* Alert Notification Panel */
.alert-panel {
    padding: 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
}

.alert-panel-success {
    background-color: var(--success-light);
    border-color: #a7f3d0;
    color: #065f46;
}

.alert-panel-warning {
    background-color: var(--warning-light);
    border-color: #fde68a;
    color: #92400e;
}

/* Details columns lists */
.details-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.details-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.details-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.details-label {
    font-weight: 600;
    color: var(--text-muted);
}

.details-val {
    color: var(--text-main);
    font-weight: 500;
}
