/**
 * Dashboard.css
 * CRM Dashboard Styles
 */

/* Dashboard Container */
.crm-dashboard {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg-primary, #f8fafc);
    z-index: 9999;
    display: none;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-dashboard.active {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: 70px 1fr;
    opacity: 1;
    transform: translateY(0);
}

/* Dashboard Header */
.dashboard-header {
    grid-column: 1 / -1;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.dashboard-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dashboard-brand i {
    font-size: 1.75rem;
    color: #3b82f6;
}

.dashboard-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.dashboard-user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-weight: 600;
    color: #1e293b;
}

.user-role {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-weight: 600;
    text-transform: uppercase;
}

.user-role.admin {
    background: linear-gradient(135deg, #f97316 0%, #ec4899 100%);
    color: white;
}

.user-role.user {
    background: #e0f2fe;
    color: #0369a1;
}

.btn-dashboard-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-dashboard-close:hover {
    background: #fee2e2;
    color: #dc2626;
    transform: rotate(90deg);
}

/* Dashboard Sidebar */
.dashboard-sidebar {
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 1.5rem 0;
}

.dashboard-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    color: #64748b;
    text-decoration: none;
    border-radius: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.125rem;
}

.nav-item span:first-of-type {
    flex: 1;
}

.nav-item .badge {
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: #e2e8f0;
    color: #475569;
}

.nav-item .badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.nav-item .badge-warning {
    background: #fef3c7;
    color: #b45309;
}

.nav-item:hover {
    background: #f8fafc;
    color: #3b82f6;
}

.nav-item.active {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1e40af;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 0 4px 4px 0;
}

/* Dashboard Content */
.dashboard-content {
    background: var(--bg-primary, #f8fafc);
    overflow-y: auto;
    padding: 2rem;
}

.dashboard-panel {
    display: none;
    animation: fadeInUp 0.4s ease;
}

.dashboard-panel.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Panel Header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.panel-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.panel-header p {
    color: #64748b;
    margin: 0.5rem 0 0 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.stat-primary .stat-icon {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
}

.stat-success .stat-icon {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.stat-warning .stat-icon {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #b45309;
}

.stat-info .stat-icon {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #4338ca;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.stat-label {
    color: #64748b;
    font-size: 0.875rem;
    margin: 0.25rem 0 0.5rem 0;
}

.stat-change {
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.positive {
    color: #10b981;
}

.stat-change.negative {
    color: #ef4444;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.dashboard-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.chart-filter {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: white;
    color: #475569;
    cursor: pointer;
}

.view-all {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
}

.view-all:hover {
    text-decoration: underline;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0.75rem;
    transition: background 0.2s ease;
}

.activity-item:hover {
    background: #f8fafc;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.activity-icon.bg-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.activity-icon.bg-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.activity-icon.bg-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.activity-content p {
    margin: 0 0 0.25rem 0;
    color: #1e293b;
}

.activity-content small {
    color: #94a3b8;
}

/* Data Table */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: white;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-group {
    display: flex;
    gap: 0.75rem;
}

.filter-select {
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: white;
    cursor: pointer;
}

.data-table {
    background: white;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-cell img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: #f1f5f9;
    color: #3b82f6;
}

/* Pagination */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
}

.pagination-info {
    color: #64748b;
    font-size: 0.875rem;
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-page {
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 0.5rem;
    cursor: pointer;
    color: #475569;
    transition: all 0.2s ease;
}

.btn-page:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #3b82f6;
    color: #3b82f6;
}

.btn-page.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.project-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.project-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.project-status {
    padding: 0.375rem 0.875rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-progress {
    background: #dbeafe;
    color: #1e40af;
}

.project-client {
    color: #64748b;
    font-size: 0.875rem;
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-progress {
    margin-bottom: 1rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.progress-info span:first-child {
    color: #64748b;
}

.progress-info span:last-child {
    color: #3b82f6;
    font-weight: 600;
}

.progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 1rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 1rem;
    transition: width 0.3s ease;
}

.project-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.875rem;
}

.meta-item i {
    color: #94a3b8;
}

.project-team {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.team-avatars {
    display: flex;
    align-items: center;
}

.team-avatars img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid white;
    margin-left: -8px;
}

.team-avatars img:first-child {
    margin-left: 0;
}

.more-users {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    border: 2px solid white;
    margin-left: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
}

/* Kanban Board */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.kanban-column {
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    min-height: 400px;
}

.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f1f5f9;
}

.column-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.task-count {
    background: #e2e8f0;
    color: #475569;
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.task-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.task-item h4 {
    font-size: 0.938rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
}

.task-item p {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0 0 0.75rem 0;
}

.task-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.priority {
    padding: 0.25rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.priority-high {
    background: #fee2e2;
    color: #dc2626;
}

.due-date {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Settings */
.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.settings-section {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.settings-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 1.5rem 0;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: #475569;
    font-size: 0.875rem;
}

.form-group input {
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Dark Theme */
body.dark-theme .crm-dashboard {
    background: #0f172a;
}

body.dark-theme .dashboard-header {
    background: #1e293b;
    border-bottom-color: #334155;
}

body.dark-theme .dashboard-brand h1 {
    color: #f1f5f9;
}

body.dark-theme .user-name {
    color: #f1f5f9;
}

body.dark-theme .dashboard-sidebar {
    background: #1e293b;
    border-right-color: #334155;
}

body.dark-theme .nav-item {
    color: #94a3b8;
}

body.dark-theme .nav-item:hover {
    background: #334155;
    color: #60a5fa;
}

body.dark-theme .nav-item.active {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: #bfdbfe;
}

body.dark-theme .dashboard-content {
    background: #0f172a;
}

body.dark-theme .panel-header h2,
body.dark-theme .stat-value,
body.dark-theme .card-header h3,
body.dark-theme .activity-content p,
body.dark-theme .data-table td,
body.dark-theme .project-header h3,
body.dark-theme .settings-section h3,
body.dark-theme .task-item h4 {
    color: #f1f5f9;
}

body.dark-theme .stat-card,
body.dark-theme .dashboard-card,
body.dark-theme .data-table,
body.dark-theme .project-card,
body.dark-theme .settings-section,
body.dark-theme .kanban-column {
    background: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark-theme .data-table th {
    background: #0f172a;
    border-bottom-color: #334155;
}

body.dark-theme .data-table td {
    border-bottom-color: #334155;
}

body.dark-theme .data-table tbody tr:hover {
    background: #334155;
}

body.dark-theme .task-item {
    background: #0f172a;
    border-color: #334155;
}

body.dark-theme .search-box input,
body.dark-theme .filter-select,
body.dark-theme .chart-filter,
body.dark-theme .form-group input {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-theme .btn-page {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

body.dark-theme .btn-page:hover:not(:disabled) {
    background: #334155;
}

/* Responsive */
@media (max-width: 1024px) {
    .crm-dashboard.active {
        grid-template-columns: 220px 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .crm-dashboard.active {
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar {
        display: none;
    }

    .dashboard-header {
        padding: 0 1rem;
    }

    .dashboard-brand h1 {
        font-size: 1.25rem;
    }

    .dashboard-content {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .table-toolbar {
        flex-direction: column;
    }

    .search-box {
        max-width: 100%;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .kanban-board {
        grid-template-columns: 1fr;
    }
}
