/* =========================================
   1. VARIABLES & THEME CONFIGURATION
   ========================================= */
:root {
    /* Brand Colors - Easy to change globally here */
    --kap-primary: #2563eb;   /* Royal Blue (Primary Buttons/Links) */
    --kap-secondary: #64748b; /* Slate Gray (Secondary Text/Borders) */
    --kap-success: #10b981;   /* Emerald Green (Success Messages/Badges) */
    --kap-warning: #f59e0b;   /* Amber (Pending Actions) */
    --kap-danger: #ef4444;    /* Red (Alerts/NCRs/Delete) */
    
    /* Backgrounds & Surfaces */
    --kap-bg: #f8fafc;        /* Main Page Background */
    --kap-surface: #ffffff;   /* Card Background */
    --kap-border: #e2e8f0;    /* Border Colors */
    
    /* Typography */
    --kap-text: #334155;      /* Body Text */
    --kap-heading: #0f172a;   /* Headings H1-H6 */
}

/* =========================================
   2. CORE LAYOUT & GRID SYSTEM
   ========================================= */
.kap-wrap {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 1200px;
    margin: 20px auto;
    color: var(--kap-text);
    box-sizing: border-box;
}

/* Ensures padding doesn't break widths */
.kap-wrap * { 
    box-sizing: border-box; 
}

/* Responsive 2-Column Grid */
.kap-grid {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Left (2 parts) | Right (1 part) */
    gap: 24px;
    align-items: start;
}

/* Mobile Responsive Breakpoint */
@media (max-width: 900px) {
    .kap-grid { 
        grid-template-columns: 1fr; /* Stack visually on mobile */
    }
}

/* =========================================
   3. CARDS & CONTAINERS
   ========================================= */
.kap-card {
    background: var(--kap-surface);
    border: 1px solid var(--kap-border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Soft Shadow */
    padding: 24px;
    margin-bottom: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Hover Effect for Interactivity */
.kap-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.kap-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--kap-border);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.kap-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--kap-heading);
}

/* =========================================
   4. TYPOGRAPHY & FORM ELEMENTS
   ========================================= */
.kap-wrap h1, 
.kap-wrap h2, 
.kap-wrap h3 { 
    color: var(--kap-heading); 
}

.kap-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--kap-secondary);
    margin-bottom: 6px;
}

/* Unified Input Styling */
.kap-input, 
.kap-select, 
.kap-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--kap-border);
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    background: #fff;
    color: var(--kap-text);
    transition: border-color 0.2s;
}

/* Focus State (Blue Glow) */
.kap-input:focus, 
.kap-select:focus, 
.kap-textarea:focus {
    border-color: var(--kap-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* =========================================
   5. BUTTONS & BADGES (UI COMPONENTS)
   ========================================= */
.kap-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

/* Button Variants */
.kap-btn-primary { background: var(--kap-primary); color: white; }
.kap-btn-primary:hover { background: #1d4ed8; }

.kap-btn-secondary { background: white; border: 1px solid var(--kap-border); color: var(--kap-secondary); }
.kap-btn-secondary:hover { background: #f1f5f9; color: var(--kap-heading); }

.kap-btn-success { background: var(--kap-success); color: white; }
.kap-btn-success:hover { background: #059669; }

.kap-btn-danger { background: var(--kap-danger); color: white; }
.kap-btn-danger:hover { background: #dc2626; }

.kap-btn-warning { background: var(--kap-warning); color: white; }

/* Status Badges (Pills) */
.kap-badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.kap-badge-blue { background: #dbeafe; color: #1e40af; }
.kap-badge-green { background: #d1fae5; color: #065f46; }
.kap-badge-yellow { background: #fef3c7; color: #92400e; }
.kap-badge-red { background: #fee2e2; color: #991b1b; }
.kap-badge-gray { background: #f1f5f9; color: #475569; }

/* =========================================
   6. CLIENT PORTAL SPECIFIC STYLES
   ========================================= */
/* Hero Section */
.kap-hero {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 40px;
    border-radius: 16px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 25px -5px rgba(30, 41, 59, 0.3);
}

.kap-hero h2 { color: white; margin: 0 0 5px 0; font-size: 2rem; }
.kap-hero p { color: #cbd5e1; margin: 0; }

/* Progress Stepper */
.kap-stepper-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
    padding: 0 10px;
}

.kap-step-item {
    flex: 1;
    text-align: center;
    position: relative;
    z-index: 2;
}

.kap-step-circle {
    width: 32px;
    height: 32px;
    background: #e2e8f0;
    color: #64748b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-weight: bold;
    border: 4px solid #fff;
    transition: all 0.3s;
}

.kap-step-item.active .kap-step-circle {
    background: var(--kap-primary);
    color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
    transform: scale(1.1);
}

.kap-step-item.completed .kap-step-circle {
    background: var(--kap-success);
    color: white;
}

.kap-step-line {
    position: absolute;
    top: 16px;
    left: 0;
    width: 100%;
    height: 3px;
    background: #e2e8f0;
    z-index: 1;
}
.kap-step-line.filled { background: var(--kap-success); }

/* Tabs Navigation */
.kap-tabs {
    display: flex;
    border-bottom: 2px solid var(--kap-border);
    margin-bottom: 24px;
    gap: 20px;
    overflow-x: auto; /* Handle overflow on mobile */
}

.kap-tab-btn {
    padding: 12px 0;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--kap-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px; /* To sit on the line */
    transition: color 0.2s;
    white-space: nowrap;
}

.kap-tab-btn:hover { color: var(--kap-primary); }

.kap-tab-btn.active {
    color: var(--kap-primary);
    border-bottom-color: var(--kap-primary);
    font-weight: 700;
}

.kap-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}
.kap-tab-content.active { display: block; }

/* Smooth Fade In Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   7. TABLES
   ========================================= */
.kap-table {
    width: 100%;
    border-collapse: collapse;
}

.kap-table th {
    text-align: left;
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--kap-border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--kap-secondary);
    font-weight: 600;
}

.kap-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--kap-border);
    font-size: 14px;
    vertical-align: middle;
}

.kap-table tr:last-child td { border-bottom: none; }
.kap-table tr:hover td { background-color: #f8fafc; }



/* --- FIXES START HERE --- */

/* 1. Fix Tab Badge Vertical Alignment */
.kap-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

/* 2. Fix Stepper on Mobile (Horizontal Scroll) */
@media (max-width: 768px) {
    .kap-stepper-container {
        overflow-x: auto;
        padding-bottom: 10px;
        justify-content: flex-start;
        gap: 15px;
    }
    .kap-step-item {
        min-width: 80px; /* Prevent shrinking */
        flex: none; 
    }
    .kap-step-line {
        display: none; /* Hide lines on mobile to prevent breakage */
    }
}