/* ===================================
   GEMENSAM CSS FÖR HELA CRM-SYSTEMET
   =================================== */

/* ===== RESET & GRUNDLÄGGANDE ===== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f6fa;
}

/* ===== LAYOUT STRUKTUR ===== */
.container {
    display: flex;
    min-height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, #003366 0%, #004080 100%);
    color: white;
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Sidebar */
aside {
    width: 250px;
    background: linear-gradient(180deg, #003366 0%, #002244 100%);
    color: #fff;
    padding: 1.5rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

aside::-webkit-scrollbar {
    width: 8px;
}

aside::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

aside::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}

aside h2 {
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(255,255,255,0.2);
}

/* Sidebar Navigation */
aside nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

aside nav strong {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

aside nav a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

aside nav a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: translateX(5px);
}

aside nav a.active {
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-weight: 600;
}

/* Main Content */
main {
    margin-left: 250px;
    margin-top: 60px;
    padding: 2rem;
    min-height: calc(100vh - 60px);
    width: calc(100% - 250px);
}

.page-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

/* Footer */
footer {
    background: #003366;
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-left: 250px;
    margin-top: auto;
}

/* ===== KORT & SEKTIONER ===== */
.card, .section-card, .dashboard-box, .settings-box {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover, .section-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.card h2, .section-card h2, .dashboard-box h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #2c3e50;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card h3, .section-card h3 {
    color: #34495e;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

/* ===== FORMULÄR ===== */
form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

label {
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="password"],
select,
textarea {
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    width: 100%;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===== KNAPPAR ===== */
button, .btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

button[type="submit"], .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

button[type="submit"]:hover, .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.status-button {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    text-align: center;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    text-decoration: none;
    color: white;
}

.status-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.status-button.blue {
    background: #007bff;
}

.status-button.green {
    background: #28a745;
}

.status-button.yellow {
    background: #ffc107;
    color: #212529;
}

.status-button.gray {
    background: #6c757d;
}

/* ===== TABELLER ===== */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

thead {
    background: #f8f9fa;
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
}

td {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

tr:hover {
    background: #f8f9fa;
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 2rem;
}

/* ===== STATUS & BADGES ===== */
.status-badge, .badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-prospekt {
    color: #856404;
    background: #fff3cd;
}

.status-lead {
    color: #8a4f00;
    background: #ffe0b2;
}

.status-kund {
    color: #155724;
    background: #d4edda;
}

.status-ej {
    color: #721c24;
    background: #f8d7da;
}

.status-privat {
    color: #004085;
    background: #cce5ff;
}

/* Hethet färger */
.hethet-het {
    color: #dc3545;
}

.hethet-varm {
    color: #fd7e14;
}

.hethet-ljummen {
    color: #ffc107;
}

.hethet-kall {
    color: #6c757d;
}

.hethet-avslutad {
    color: #28a745;
}

/* ===== STATISTIK KORT ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: transform 0.2s ease;
}

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

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
    margin: 0;
}

.stat-label {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* ===== AI SEKTIONER ===== */
.ai-panel {
    background: linear-gradient(135deg, #f5f3ff 0%, #e9e6ff 100%);
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid #d4ccff;
}

.ai-box {
    background: #f0f8ff;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    margin: 1rem 0;
}

.ai-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.ai-button {
    padding: 1.2rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: left;
}

.ai-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.ai-button-risk {
    background: linear-gradient(135deg, #fc5c7d 0%, #eb3349 100%);
}

.ai-button-checklist {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.ai-button-requirements {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.ai-button-recommendations {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.ai-button-timeline {
    background: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 100%);
}

/* ===== MEDDELANDEN & ALERTS ===== */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ===== LOADING & SPINNERS ===== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ===== MODALS & POPUPS ===== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1001;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* ===== TABS ===== */
.tab-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.tab-button {
    padding: 0.8rem 1.5rem;
    background: none;
    border: none;
    font-weight: 600;
    color: #7f8c8d;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-button:hover {
    color: #34495e;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

/* ===== EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #999;
}

.empty-state img {
    width: 100px;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: #666;
    margin-bottom: 0.5rem;
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #6c757d; }
.text-primary { color: #667eea; }
.text-success { color: #28a745; }
.text-danger { color: #dc3545; }
.text-warning { color: #ffc107; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

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

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* ===== RESPONSIV DESIGN ===== */
@media (max-width: 1200px) {
    .stat-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 992px) {
    /* Göm sidebar på mindre skärmar */
    aside {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    aside.open {
        transform: translateX(0);
    }
    
    header {
        left: 0;
    }
    
    main {
        margin-left: 0;
        width: 100%;
    }
    
    footer {
        margin-left: 0;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .ai-buttons {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    main {
        padding: 1rem;
        margin-top: 50px;
    }
    
    .card, .section-card {
        padding: 1.5rem;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.75rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .modal {
        padding: 1.5rem;
    }
    
    table {
        font-size: 0.85rem;
    }
    
    th, td {
        padding: 0.5rem;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    aside, header, footer {
        display: none;
    }
    
    main {
        margin: 0;
        width: 100%;
    }
    
    .no-print {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.3; }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== DARK MODE (om du vill implementera senare) ===== */
@media (prefers-color-scheme: dark) {
    /* Lägg till dark mode styles här om önskat */
}