/* ===== BASE STYLES ===== */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #1abc9c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --gray-color: #95a5a6;
    --border-color: #ddd;
    --shadow-color: rgba(0,0,0,0.1);
    --sidebar-width: 280px;
    --topbar-height: 60px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.login-header .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.login-header .logo i {
    font-size: 2.5rem;
    color: white;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 600;
}

.login-header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.login-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.5s ease;
}

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

.tabs {
    display: flex;
    margin-bottom: 25px;
    border-bottom: 2px solid #f0f0f0;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 500;
    color: var(--gray-color);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--secondary-color);
    border-radius: 3px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group .password-toggle {
    position: absolute;
    right: 15px;
    top: 40px;
    cursor: pointer;
    color: var(--gray-color);
}

.password-strength {
    margin-top: 8px;
}

.strength-bar {
    height: 4px;
    background: #eee;
    border-radius: 2px;
    overflow: hidden;
}

.strength-text {
    font-size: 12px;
    color: var(--gray-color);
    display: block;
    margin-top: 4px;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.admin-note {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--warning-color);
}

.admin-note p {
    margin: 0;
    font-size: 14px;
}

.admin-note code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.login-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
}

.login-footer .version {
    font-size: 12px;
    color: var(--gray-color);
    margin-bottom: 5px;
}

.login-footer .contact {
    font-size: 13px;
    color: var(--primary-color);
}

.status-bar {
    margin-top: 20px;
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    color: white;
    font-size: 14px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-online .fa-circle { color: var(--success-color); }
.status-offline .fa-circle { color: var(--gray-color); }
.status-error .fa-circle { color: var(--danger-color); }

/* ===== APP LAYOUT ===== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: white;
    box-shadow: 0 2px 10px var(--shadow-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 1000;
}

.topbar .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: var(--primary-color);
    color: white;
    padding: 20px;
    overflow-y: auto;
    transition: transform 0.3s;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    margin-bottom: 30px;
}

.user-profile .avatar {
    font-size: 40px;
    color: white;
}

.profile-info h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
}

.role-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--secondary-color);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

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

.role-badge.tech {
    background: var(--success-color);
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 30px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s;
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: var(--secondary-color);
    color: white;
}

.nav-item .badge {
    position: absolute;
    right: 15px;
    background: var(--danger-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.system-status,
.inbox-stats,
.group-stats,
.history-stats,
.admin-stats {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 15px;
    margin-top: auto;
}

.status-item,
.stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.stat-card:last-child {
    margin-bottom: 0;
}

.stat-card i {
    font-size: 24px;
    color: var(--secondary-color);
}

.stat-card h4 {
    margin: 0;
    font-size: 24px;
}

.stat-card small {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
}

.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 30px;
    min-height: calc(100vh - var(--topbar-height));
    background: #f8f9fa;
}

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

.content-header h2 {
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

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

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

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

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

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

.btn-outline {
    background: transparent;
    color: var(--secondary-color);
    border: 2px solid var(--secondary-color);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: var(--gray-color);
    transition: color 0.3s;
}

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

/* ===== FORMS ===== */
.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* ===== TABLES ===== */
.data-table-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px var(--shadow-color);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8f9fa;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-color);
    cursor: pointer;
    transition: color 0.3s;
}

.btn-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 30px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-info {
    background: #e3f2fd;
    color: #1565c0;
    border-left: 4px solid #2196f3;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #4caf50;
}

.alert-warning {
    background: #fff3e0;
    color: #ef6c00;
    border-left: 4px solid #ff9800;
}

.alert-danger {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #f44336;
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.in_stock {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.assigned {
    background: #e3f2fd;
    color: #1565c0;
}

.status-badge.in_repair {
    background: #fff3e0;
    color: #ef6c00;
}

.status-badge.retired {
    background: #f5f5f5;
    color: #616161;
}

.status-badge.lost {
    background: #ffebee;
    color: #c62828;
}

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    flex-direction: column;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--primary-color);
    font-size: 16px;
}

/* ===== INBOX LAYOUT ===== */
.inbox-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    height: calc(100vh - var(--topbar-height) - 60px);
}

.threads-panel,
.messages-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-color);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-box {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

.search-box i {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-color);
}

.threads-list,
.messages-container {
    flex: 1;
    overflow-y: auto;
}

.thread-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.3s;
    gap: 15px;
}

.thread-item:hover {
    background: #f8f9fa;
}

.thread-item.active {
    background: #e3f2fd;
    border-left: 4px solid var(--secondary-color);
}

.thread-avatar {
    width: 40px;
    height: 40px;
    background: var(--secondary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.thread-info {
    flex: 1;
    min-width: 0;
}

.thread-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-participants {
    font-size: 12px;
    color: var(--gray-color);
    margin-bottom: 4px;
}

.thread-meta {
    font-size: 11px;
    color: var(--gray-color);
    display: flex;
    gap: 10px;
}

.thread-actions {
    display: flex;
    gap: 5px;
}

.messages-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-input {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.input-tools {
    display: flex;
    gap: 5px;
}

.input-area {
    flex: 1;
}

.input-area textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
}

.attachment-preview {
    margin-top: 10px;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.attachment-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-color);
    text-align: center;
    padding: 40px;
}

.empty-state i {
    font-size: 60px;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* ===== GROUP LAYOUT ===== */
.group-layout {
    display: grid;
    grid-template-columns: 300px 1fr 250px;
    gap: 20px;
    height: calc(100vh - var(--topbar-height) - 60px);
}

.group-chat-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-color);
    display: flex;
    flex-direction: column;
}

.groups-panel,
.members-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-color);
    display: flex;
    flex-direction: column;
}

.group-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.3s;
    gap: 12px;
}

.group-item:hover {
    background: #f8f9fa;
}

.group-item.active {
    background: #e3f2fd;
}

.group-avatar {
    width: 40px;
    height: 40px;
    background: var(--info-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.unread-count {
    background: var(--danger-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.chat-input {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.members-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-color);
}

.add-members {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.add-member-input {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.add-member-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.suggested-users {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.suggested-user {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

/* ===== REPORTS LAYOUT ===== */
.reports-layout {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card-large {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 10px var(--shadow-color);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s;
}

.stat-card-large:hover {
    transform: translateY(-5px);
}

.stat-card-large .stat-icon {
    width: 60px;
    height: 60px;
    background: var(--secondary-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.stat-card-large .stat-content h3 {
    font-size: 32px;
    margin: 0 0 5px 0;
    color: var(--primary-color);
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--success-color);
}

.progress-bar {
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: var(--secondary-color);
    transition: width 0.3s;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 10px var(--shadow-color);
}

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

.chart-header h4 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.chart-container {
    height: 300px;
    position: relative;
}

.table-card,
.system-health {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 10px var(--shadow-color);
}

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

.table-container {
    overflow-x: auto;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.health-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.health-icon {
    width: 50px;
    height: 50px;
    background: var(--secondary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.health-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

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

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

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .inbox-layout {
        grid-template-columns: 1fr;
    }
    
    .group-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 15px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header-actions {
        width: 100%;
        overflow-x: auto;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== UTILITIES ===== */
.text-danger { color: var(--danger-color); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-info { color: var(--info-color); }
.text-primary { color: var(--primary-color); }

.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.ml-10 { margin-left: 10px; }
.mr-10 { margin-right: 10px; }

.hidden { display: none !important; }
.admin-only { display: none; }

/* Hide admin features for non-admin users */
body:not(.admin) .admin-only {
    display: none !important;
}

body.admin .admin-only {
    display: flex !important;
}