/**
 * KeraCRM - Main Stylesheet
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --sidebar-width: 260px;
    --header-height: 60px;
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --text-muted: #6c757d;
}

/* ============================================
   Base Styles
   ============================================ */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f5f7fb;
    min-height: 100vh;
}

a {
    text-decoration: none;
    transition: color 0.2s ease;
}

/* ============================================
   Layout
   ============================================ */
#app {
    min-height: 100vh;
}

.main-content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #1e3a5f 0%, #0d1b2a 100%);
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--primary-color);
}

.sidebar .nav-link i {
    width: 24px;
}

/* ============================================
   Header/Navbar
   ============================================ */
.navbar {
    height: var(--header-height);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    position: relative;
    z-index: 1030;
}

.navbar .dropdown-menu {
    z-index: 1031;
}

/* ============================================
   Cards
   ============================================ */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.card-title {
    margin-bottom: 0;
    font-weight: 600;
}

/* ============================================
   Stats Cards
   ============================================ */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.15;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============================================
   Tables
   ============================================ */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    padding: 1rem 0.75rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: #5a6fd6;
    border-color: #5a6fd6;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Forms
   ============================================ */
.form-control,
.form-select {
    border-radius: 0.5rem;
    border-color: var(--border-color);
    padding: 0.625rem 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #344054;
}

.input-group-text {
    border-radius: 0.5rem;
    border-color: var(--border-color);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
}

.badge-status {
    font-size: 0.75rem;
}

/* Status Colors */
.bg-status-planned { background-color: #e3f2fd !important; color: #1976d2 !important; }
.bg-status-completed { background-color: #e8f5e9 !important; color: #388e3c !important; }
.bg-status-cancelled { background-color: #ffebee !important; color: #d32f2f !important; }
.bg-status-pending { background-color: #fff3e0 !important; color: #f57c00 !important; }
.bg-status-in_progress { background-color: #e3f2fd !important; color: #1976d2 !important; }

/* Priority Colors */
.bg-priority-low { background-color: #e8f5e9 !important; color: #388e3c !important; }
.bg-priority-medium { background-color: #fff3e0 !important; color: #f57c00 !important; }
.bg-priority-high { background-color: #ffebee !important; color: #d32f2f !important; }
.bg-priority-urgent { background-color: #d32f2f !important; color: #fff !important; }

/* ============================================
   Avatar
   ============================================ */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0;
}

.page-header .breadcrumb {
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem;
}

.empty-state i {
    font-size: 4rem;
    color: var(--border-color);
    margin-bottom: 1rem;
}

.empty-state h4 {
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================
   Loading
   ============================================ */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Dropdown
   ============================================ */
.dropdown-menu {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
}

.dropdown-item:hover {
    background-color: var(--light-color);
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    border: none;
    border-radius: 0.75rem;
}

/* ============================================
   Modal
   ============================================ */
.modal-content {
    border: none;
    border-radius: 1rem;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: 0.5rem;
    border: none;
    padding: 0.5rem 0.875rem;
}

.page-item.active .page-link {
    background-color: var(--primary-color);
}

/* ============================================
   Utilities
   ============================================ */
.text-primary { color: var(--primary-color) !important; }
.bg-primary { background-color: var(--primary-color) !important; }
.border-primary { border-color: var(--primary-color) !important; }

.cursor-pointer { cursor: pointer; }

.shadow-sm { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important; }
.shadow { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important; }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar {
        display: none;
    }

    .main-content {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }
}
