/* ============================================================
   Intermediary AS — CRM System Stylesheet
   ============================================================ */

:root {
    --primary: #2BC48A;
    --primary-dark: #1a9e6a;
    --primary-light: #f0fdf8;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --sidebar-width: 260px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --radius: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'DM Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #F5F5F5;
    color: var(--gray-800);
    line-height: 1.6;
}

#app {
    display: flex;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
#sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e3a5f 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header .subtitle {
    font-size: 0.72rem;
    color: #2BC48A;
    display: block;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
}

.nav-menu {
    list-style: none;
    flex: 1;
    padding: 0.5rem 0;
}

.nav-item {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.65);
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-item.active {
    background: rgba(43,196,138,0.12);
    color: #fff;
    border-left-color: #2BC48A;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ==================== MAIN CONTENT ==================== */
#main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    max-width: 100%;
    overflow-x: hidden;
}

.page { display: none; }
.page.active { display: block; }

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

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

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

.date-display {
    color: var(--gray-500);
    font-size: 0.9rem;
}

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

.btn-primary {
    background: #2BC48A;
    color: #fff;
}
.btn-primary:hover { background: #1a9e6a; }

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }

#sidebar .btn-outline {
    border-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
}
#sidebar .btn-outline:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-color: #2BC48A;
}

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

/* ==================== KPI CARDS ==================== */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow 0.2s ease;
}

.kpi-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
    color: #2BC48A;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    display: block;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    display: block;
}

/* ==================== CARDS ==================== */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

/* ==================== TABLES ==================== */
.table-container {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

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

th {
    background: var(--gray-50);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
    color: var(--gray-700);
}

tr:hover td {
    background: #f8fafc;
}

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

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: #fff;
    color: var(--gray-800);
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #2BC48A;
    box-shadow: 0 0 0 3px rgba(43,196,138,0.15);
}

.search-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.875rem;
    min-width: 200px;
}

.filter-select {
    min-width: 150px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.checkbox-label {
    display: flex !important;
    align-items: flex-start;
    gap: 0.5rem;
    font-weight: 400 !important;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-top: 0.25rem;
}

.gdpr-consent-group {
    background: var(--warning-light);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--warning);
}

/* ==================== MODALS ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius);
    width: 90%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-content.modal-lg {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0;
    line-height: 1;
}
.modal-close:hover { color: var(--gray-800); }

.modal-content form {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

/* ==================== PIPELINE ==================== */
.pipeline-stage {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.stage-name {
    width: 120px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-600);
}

.stage-bar {
    flex: 1;
    height: 24px;
    background: var(--gray-100);
    border-radius: 12px;
    overflow: hidden;
}

.stage-fill {
    height: 100%;
    background: #2BC48A;
    border-radius: 12px;
    transition: width 0.5s ease;
}

.stage-fill.contacted { background: #3b82f6; }
.stage-fill.meeting { background: #8b5cf6; }
.stage-fill.offer { background: var(--warning); }
.stage-fill.won { background: var(--success); }
.stage-fill.lost { background: var(--danger); }

.stage-count {
    width: 30px;
    text-align: right;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* ==================== STATUS BADGES ==================== */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-ny { background: var(--primary-light); color: var(--primary); }
.badge-kontaktet { background: #dbeafe; color: #2563eb; }
.badge-møte { background: #ede9fe; color: #7c3aed; }
.badge-tilbud { background: var(--warning-light); color: var(--warning); }
.badge-vunnet { background: var(--success-light); color: var(--success); }
.badge-tapt { background: var(--danger-light); color: var(--danger); }
.badge-aktiv { background: var(--success-light); color: var(--success); }
.badge-planlegging { background: var(--primary-light); color: var(--primary); }
.badge-pause { background: var(--warning-light); color: var(--warning); }
.badge-ferdig { background: var(--gray-200); color: var(--gray-600); }
.badge-sendt { background: var(--success-light); color: var(--success); }
.badge-utkast { background: var(--gray-200); color: var(--gray-600); }
.badge-klar { background: var(--warning-light); color: var(--warning); }

.badge-gdpr-yes { background: var(--success-light); color: var(--success); }
.badge-gdpr-no { background: var(--danger-light); color: var(--danger); }

/* ==================== ACTIVITY LIST ==================== */
.activity-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.activity-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.activity-list li:last-child { border-bottom: none; }

.activity-list .activity-time {
    color: var(--gray-400);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ==================== TASK LIST ==================== */
.task-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.task-input-row input[type="text"] { flex: 1; }
.task-input-row input[type="date"] { width: 150px; }

.task-list {
    list-style: none;
    max-height: 250px;
    overflow-y: auto;
}

.task-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.task-list li.completed .task-text {
    text-decoration: line-through;
    color: var(--gray-400);
}

.task-text { flex: 1; }

.task-date {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.task-delete {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 0.8rem;
}
.task-delete:hover { color: var(--danger); }

/* ==================== STATS CARDS ==================== */
.email-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    display: block;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ==================== SOCIAL MEDIA ==================== */
.social-channels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.social-channel-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.social-channel-card i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.social-channel-card h3 {
    justify-content: center;
    margin-bottom: 0.75rem;
}

.social-stats {
    display: flex;
    justify-content: space-around;
    gap: 0.5rem;
}

.social-stats > div {
    text-align: center;
}

/* ==================== CAMPAIGNS ==================== */
.campaigns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.campaign-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.campaign-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

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

.campaign-card-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.campaign-card-body {
    padding: 1rem 1.25rem;
}

.campaign-meta {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

.campaign-progress {
    margin-top: 0.75rem;
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.progress-fill {
    height: 100%;
    background: #2BC48A;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.campaign-card-actions {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 0.5rem;
}

/* ==================== GDPR ==================== */
.gdpr-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.gdpr-overview .full-width {
    grid-column: 1 / -1;
}

.gdpr-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

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

.gdpr-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--success);
    display: block;
}

.gdpr-stat-value.gdpr-warning { color: var(--danger); }

.gdpr-stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.gdpr-policy p {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.gdpr-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ==================== SEARCH / COMPANY ==================== */
.search-container {
    margin-bottom: 1.5rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.search-box input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.search-filters {
    display: flex;
    gap: 0.75rem;
}

.search-results {
    min-height: 200px;
}

.company-result-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s ease;
}

.company-result-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.company-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.company-info p {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 0.15rem;
}

.api-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #f0fdf8;
    border: 1px solid #2BC48A;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: #0f172a;
}

/* ==================== NEWSLETTER PREVIEW ==================== */
.newsletter-preview {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

/* ==================== CHECKBOX LIST ==================== */
.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.5rem;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-radius: 4px;
}

.checkbox-list label:hover {
    background: var(--gray-50);
}

/* ==================== SETTINGS ==================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1rem;
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
    color: var(--gray-400);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.5rem 0;
}

.empty-state-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--gray-400);
    text-align: center;
}

.empty-state-large i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ==================== CHART ==================== */
.chart-placeholder {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== ACTION BUTTONS (TABLE) ==================== */
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.375rem;
    border-radius: 4px;
    color: var(--gray-500);
    font-size: 0.85rem;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.action-btn.edit:hover { color: var(--primary); }
.action-btn.delete:hover { color: var(--danger); }

.text-muted { color: var(--gray-500); font-size: 0.8rem; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    #sidebar {
        width: 60px;
        overflow: visible;
    }
    .sidebar-header h2 span,
    .nav-item span,
    .sidebar-header .subtitle,
    .sidebar-footer { display: none; }
    .nav-item { padding: 0.75rem; justify-content: center; }
    .nav-item i { width: auto; }
    #main-content { margin-left: 60px; padding: 1rem; }
    .form-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
