/* OpsightCRM Styles - Matching original Firebase Studio design */

:root {
    /* Light mode colors */
    --background: hsl(0, 0%, 96.1%);
    --foreground: hsl(224, 71.4%, 4.1%);
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(224, 71.4%, 4.1%);
    --popover: hsl(0, 0%, 100%);
    --popover-foreground: hsl(224, 71.4%, 4.1%);
    --primary: hsl(197, 78%, 52%);
    --primary-foreground: hsl(210, 20%, 98%);
    --secondary: hsl(220, 13%, 91%);
    --secondary-foreground: hsl(220.9, 39.3%, 11%);
    --muted: hsl(220, 13%, 91%);
    --muted-foreground: hsl(220, 8.9%, 46.1%);
    --accent: hsl(120, 73%, 75%);
    --accent-foreground: hsl(220.9, 39.3%, 11%);
    --destructive: hsl(0, 84.2%, 60.2%);
    --destructive-foreground: hsl(210, 20%, 98%);
    --border: hsl(220, 13%, 87%);
    --input: hsl(220, 13%, 87%);
    --ring: hsl(197, 78%, 52%);
    --radius: 0.5rem;

    /* Chart colors */
    --chart-1: hsl(197, 78%, 52%);
    --chart-2: hsl(120, 73%, 75%);
    --chart-3: hsl(40, 80%, 60%);
    --chart-4: hsl(280, 65%, 60%);
    --chart-5: hsl(340, 75%, 55%);

    /* Sidebar */
    --sidebar-background: hsl(0, 0%, 100%);
    --sidebar-foreground: hsl(224, 71.4%, 4.1%);
    --sidebar-primary: hsl(197, 78%, 52%);
    --sidebar-accent: hsl(220, 13%, 91%);
}

[data-theme="dark"] {
    --background: hsl(218, 48%, 13%);
    --foreground: hsl(210, 40%, 98%);
    --card: hsla(217, 33%, 17%, 0.6);
    --card-foreground: hsl(210, 40%, 98%);
    --popover: hsl(217, 33%, 17%);
    --popover-foreground: hsl(210, 40%, 98%);
    --primary: hsl(210, 100%, 50%);
    --primary-foreground: hsl(210, 40%, 98%);
    --secondary: hsl(217, 33%, 20%);
    --secondary-foreground: hsl(210, 40%, 98%);
    --muted: hsl(217, 33%, 20%);
    --muted-foreground: hsl(215, 20.2%, 65.1%);
    --accent: hsl(217, 33%, 25%);
    --accent-foreground: hsl(210, 40%, 98%);
    --destructive: hsl(0, 63%, 31%);
    --destructive-foreground: hsl(210, 40%, 98%);
    --border: hsl(217, 33%, 25%);
    --input: hsl(217, 33%, 25%);
    --ring: hsl(210, 100%, 50%);
    --sidebar-background: hsla(217, 33%, 17%, 0.8);
    --sidebar-foreground: hsl(210, 40%, 98%);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body {
    background: radial-gradient(ellipse at top, hsl(218, 48%, 18%) 0%, hsl(218, 48%, 10%) 100%);
    background-attachment: fixed;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 64px;
    background-color: var(--sidebar-background);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    position: fixed;
    height: 100vh;
    z-index: 50;
}

[data-theme="dark"] .sidebar {
    backdrop-filter: blur(10px);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 2rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.sidebar-link {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--muted-foreground);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}

.sidebar-link:hover {
    background-color: var(--sidebar-accent);
    color: var(--foreground);
}

.sidebar-link.active {
    background-color: var(--primary);
    color: white;
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
}

.sidebar-link .tooltip {
    position: absolute;
    left: 60px;
    background: var(--popover);
    color: var(--popover-foreground);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.sidebar-link:hover .tooltip {
    opacity: 1;
}

.sidebar-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 64px;
    min-height: 100vh;
}

/* Header */
.header {
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background-color: var(--card);
    position: sticky;
    top: 0;
    z-index: 40;
}

[data-theme="dark"] .header {
    background-color: var(--card);
    backdrop-filter: blur(10px);
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
}

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

.user-dropdown {
    position: relative;
}

.user-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.user-button:hover {
    background-color: var(--muted);
}

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

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    min-width: 160px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 50;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    color: var(--foreground);
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background-color: var(--muted);
}

.dropdown-item.destructive {
    color: var(--destructive);
}

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

/* Page content */
.page-content {
    padding: 1.5rem;
}

/* Cards */
.card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .card {
    backdrop-filter: blur(10px);
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.card-description {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.card-content {
    padding: 1.5rem;
}

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

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
}

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

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

.stat-card {
    padding: 1.5rem;
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    font-weight: 500;
}

.stat-icon {
    width: 16px;
    height: 16px;
    color: var(--muted-foreground);
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
}

.stat-change {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

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

.btn-primary:hover {
    opacity: 0.9;
}

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

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

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

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

.btn-ghost {
    background-color: transparent;
    color: var(--foreground);
}

.btn-ghost:hover {
    background-color: var(--muted);
}

.btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

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

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    background-color: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px rgba(43, 163, 212, 0.2);
}

.form-input::placeholder {
    color: var(--muted-foreground);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

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

.form-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.form-row {
    display: grid;
    gap: 1rem;
}

@media (min-width: 640px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: var(--muted-foreground);
    border-bottom: 1px solid var(--border);
    background-color: var(--muted);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
    background-color: var(--muted);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.badge-secondary {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
}

.badge-success {
    background-color: hsl(120, 73%, 75%);
    color: hsl(120, 73%, 20%);
}

.badge-warning {
    background-color: hsl(40, 80%, 60%);
    color: hsl(40, 80%, 20%);
}

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

/* Priority badges */
.priority-high {
    background-color: hsl(0, 84%, 60%);
    color: white;
}

.priority-medium {
    background-color: hsl(40, 80%, 60%);
    color: hsl(40, 80%, 20%);
}

.priority-low {
    background-color: hsl(197, 78%, 52%);
    color: white;
}

/* Dialogs/Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background-color: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 1rem;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-description {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.modal-content {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground);
    padding: 0.25rem;
    border-radius: 4px;
}

.modal-close:hover {
    background-color: var(--muted);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
}

.tab {
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--foreground);
}

.tab.active {
    color: var(--foreground);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
    padding: 1rem 0;
}

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

/* Kanban Pipeline */
.pipeline-container {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.pipeline-column {
    min-width: 280px;
    max-width: 280px;
    background-color: var(--muted);
    border-radius: var(--radius);
    padding: 1rem;
}

.pipeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.pipeline-title {
    font-weight: 600;
    font-size: 0.875rem;
}

.pipeline-count {
    background-color: var(--background);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.pipeline-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 200px;
}

.deal-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.deal-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.deal-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.deal-card-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--muted);
}

.deal-card-title {
    font-weight: 500;
    font-size: 0.875rem;
}

.deal-card-customer {
    color: var(--muted-foreground);
    font-size: 0.75rem;
}

.deal-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.deal-card-revenue {
    font-weight: 600;
    color: var(--primary);
}

.deal-card-probability {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* Customer list with company grouping */
.customer-group {
    margin-bottom: 0.5rem;
}

.customer-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: var(--muted);
    cursor: pointer;
    border-radius: var(--radius);
    font-weight: 500;
}

.customer-group-header:hover {
    background-color: var(--secondary);
}

.customer-group-toggle {
    transition: transform 0.2s;
}

.customer-group.expanded .customer-group-toggle {
    transform: rotate(90deg);
}

.customer-group-list {
    display: none;
    padding-left: 1rem;
}

.customer-group.expanded .customer-group-list {
    display: block;
}

.customer-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.customer-item:hover {
    background-color: var(--muted);
}

.customer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--muted);
}

.customer-info {
    flex: 1;
}

.customer-name {
    font-weight: 500;
}

.customer-email {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.customer-badges {
    display: flex;
    gap: 0.25rem;
}

/* Charts placeholder */
.chart-container {
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--muted);
    border-radius: var(--radius);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-success {
    border-left: 4px solid hsl(120, 73%, 50%);
}

.toast-error {
    border-left: 4px solid var(--destructive);
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground);
    padding: 0.25rem;
}

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--muted);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--muted-foreground);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.font-bold {
    font-weight: 700;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mr-2 { margin-right: 0.5rem; }
.ml-2 { margin-left: 0.5rem; }

.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

.w-full { width: 100%; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }

/* Completed task styling */
.task-completed {
    text-decoration: line-through;
    color: var(--muted-foreground);
}

/* Radio group styling */
.radio-group {
    display: flex;
    gap: 0.5rem;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.radio-item:hover {
    border-color: var(--primary);
}

.radio-item.selected {
    border-color: var(--primary);
    background-color: rgba(43, 163, 212, 0.1);
}

.radio-item input[type="radio"] {
    display: none;
}

/* Search input */
.search-container {
    position: relative;
}

.search-container svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    width: 16px;
    height: 16px;
}

.search-input {
    padding-left: 2.5rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted-foreground);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .pipeline-container {
        flex-direction: column;
    }

    .pipeline-column {
        max-width: 100%;
    }
}
