:root {
    /* Brand Colors (from new design) */
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --bg-color: #f4f7f6;
    --text-color: #333;
    --border-color: #ddd;
    --white: #ffffff;

    /* Legacy/Bootstrap Variable Overrides */
    --brand: var(--accent-color);
    --brand-contrast: var(--white);
    --brand-light: #5dade2;
    --brand-dark: #2980b9;
    
    /* Background & Surface */
    --bg: var(--bg-color);
    --bg-secondary: #ebedef;
    --surface: var(--white);
    --surface-elevated: var(--white);
    
    /* Text Colors */
    --text-primary: var(--text-color);
    --text-secondary: var(--secondary-color);
    --text-muted: #7f8c8d;
    --text-light: #bdc3c7;

    /* Status Colors */
    --status-draft: #95a5a6;
    --status-submitted: var(--accent-color);
    --status-approved: #27ae60;
    --status-rejected: #e74c3c;
    --status-changes-requested: #f39c12;
    --status-pending: #8e44ad;

    /* Category Colors */
    --category-primary: var(--accent-color);
    --category-success: #2ecc71;
    --category-warning: #f1c40f;
    --category-danger: #e74c3c;
    --category-info: #1abc9c;
    --category-purple: #9b59b6;
    --category-pink: #e91e63;
    
    /* Borders & Shadows */
    --border-radius: 4px;
    --border-radius-sm: 4px;
    --border-radius-lg: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    
    /* Typography */
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-size-base: 1rem;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    
    /* Email Template Tabs */
    --email-tab-bg: #e2e8f0;
    --email-tab-color: #1e293b;
    --email-tab-active-bg: var(--accent-color);
    --email-tab-active-color: var(--white);
    --email-tab-hover-bg: #cbd5e1;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
}

/* Dashboard Components */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-content {
    flex-grow: 1;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.form-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.form-card {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.form-card:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.form-card-accent {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

.form-card-title {
    font-weight: 700;
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.form-card-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.form-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
}

/* Dashboard Header refinements */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    margin-top: 2rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Compact Table refinements */
.table-container {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table thead th {
    background: #f8fafc;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* Badge Refinements */
.status-badge {
    padding: 4px 10px;
    font-size: 0.75rem;
    letter-spacing: 0.01em;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: var(--font-size-base);
    line-height: 1.6;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main Container Adjustment */
.container {
    width: 98%;
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 10px;
}

/* Typography & Headings */
h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); margin-bottom: 1.5rem; }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: 1.25rem; margin-top: 1.5rem; }

p { 
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }

/* Modern Navigation (Matching new design) */
.navbar {
    background-color: var(--primary-color) !important;
    padding: 0.75rem 0;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    z-index: 4000;
    border-bottom: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    position: relative;
}

/* Email Template Tabs Styling */
#templateTabs .nav-link {
    background-color: var(--email-tab-bg);
    color: var(--email-tab-color);
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

#templateTabs .nav-link:hover {
    background-color: var(--email-tab-hover-bg);
    color: var(--text-primary);
}

#templateTabs .nav-link.active {
    background-color: var(--email-tab-active-bg) !important;
    color: var(--email-tab-active-color) !important;
    border-color: var(--email-tab-active-bg);
    box-shadow: var(--shadow-sm);
}

/* Submission View Spacing Fixes */
.answers-list .bg-light {
    padding: 1.5rem !important;
}

.table-container {
    padding: 2rem;
}

@media (max-width: 768px) {
    .table-container {
        padding: 1rem;
    }
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--white) !important;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    max-height: 40px;
    width: auto;
    object-fit: contain;
}

.nav-link {
    color: var(--white) !important;
    font-weight: 500;
    font-size: 0.9375rem;
    padding: 0.5rem 1rem !important;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--accent-color) !important;
    background: transparent;
}

.nav-link.active {
    color: var(--accent-color) !important;
    background: transparent;
}

/* Modern Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

.card h3 {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
}

.card .value {
    font-size: 2rem;
    font-weight: bold;
    margin: 10px 0;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
    color: var(--primary-color);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Question Cards */
.question-card {
    border: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
}

.question-card:hover {
    transform: none;
    box-shadow: var(--shadow-md);
}

/* Form Controls */
.form-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    margin-bottom: 0.5rem;
    display: block;
}

.form-control, .form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: var(--surface);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
    outline: none;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

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

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

.btn-success { background: var(--category-success); color: white; }
.btn-danger { background: var(--category-danger); color: white; }
.btn-warning { background: var(--category-warning); color: white; }

.btn-outline-primary {
    background: transparent;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
}

.btn-outline-primary:hover {
    background: var(--accent-color);
    color: white;
}

/* Tables */
.table-container {
    background: var(--white);
    padding: 15px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
    color: var(--secondary-color);
    font-size: var(--font-size-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 12px;
    text-align: left;
}

.table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    vertical-align: middle;
}

/* Badges & Tags */
.status-badge, .badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid #ddd;
    text-transform: capitalize;
}

.status-approved {
    background-color: #d4edda !important;
    color: #155724 !important;
    border-color: #c3e6cb !important;
}

.status-rejected {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border-color: #f5c6cb !important;
}

.status-submitted, .status-pending {
    background-color: #e2d9f3 !important;
    color: #553c7b !important;
    border-color: #d1c4e9 !important;
}

.status-draft {
    background-color: #e9ecef !important;
    color: #495057 !important;
    border-color: #dee2e6 !important;
}

.status-changes-requested, .status-requested-changes {
    background-color: #fff3cd !important;
    color: #856404 !important;
    border-color: #ffeeba !important;
}

.status-info {
    background-color: #e7f3ff !important;
    color: #007bff !important;
    border-color: #b8daff !important;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 15px;
    margin-top: 10px;
}

.tab-link {
    padding: 8px 20px;
    text-decoration: none;
    color: var(--secondary-color);
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-link.active {
    border-bottom-color: var(--accent-color);
    color: var(--accent-color);
}

/* Overview Grid */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Dashboard Row/Col */
.dashboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.dashboard-col {
    flex: 1;
    min-width: 450px;
}

/* Progress Bar */
.progress-track {
    height: 8px;
    background-color: #eee;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #2ecc71);
    border-radius: 4px;
    transition: width 0.5s ease-in-out;
}

/* Alerts */
.alert {
    padding: 12px 20px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 20px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.alert-info { background-color: #d1ecf1; color: #0c5460; border-color: #bee5eb; }
.alert-success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.alert-warning { background-color: #fff3cd; color: #856404; border-color: #ffeeba; }
.alert-danger { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }

/* Utility Classes */
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 768px) {
    .dashboard-col { min-width: 100%; }
    .btn { width: 100%; justify-content: center; margin-right: 0; }
}

/* Fix for tab text visibility (overriding nav-link white color) */
.nav-tabs .nav-link {
    color: var(--primary-color) !important;
    background-color: transparent;
    border: 1px solid transparent;
}

.nav-tabs .nav-link:hover {
    color: var(--accent-color) !important;
    background-color: rgba(0,0,0,0.05);
    border-color: transparent transparent var(--border-color);
}

.nav-tabs .nav-link.active {
    color: var(--primary-color) !important;
    background-color: var(--white) !important;
    border-color: var(--border-color) var(--border-color) var(--white);
    font-weight: 600;
}
