/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --neutral-color: #6b7280;
    --neutral-light: #f3f4f6;

    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    --transition: all 0.2s ease;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.title-group h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

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

.btn-outline:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--secondary-color);
}

.btn-large {
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

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

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

.btn-success:hover:not(:disabled) {
    background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
}

/* Cards */
.progress-card,
.config-card,
.custom-card,
.report-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.progress-card h2,
.config-card h2,
.custom-card h2,
.report-card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Progress Section */
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.progress-percentage {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.progress-bar-container {
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    border-radius: 6px;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat {
    text-align: center;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* Config Section */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.config-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.toggle-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.toggle-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.toggle-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.toggle-btn.active {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Custom Section */
.custom-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

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

.form-group label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

/* Checklist Section */
.checklist-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

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

.checklist-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.filter-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    width: 200px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    width: 250px;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    background: var(--bg-primary);
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.checklist-container {
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.9375rem;
}

/* Category Group */
.category-group {
    margin-bottom: 1.5rem;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.category-header:hover {
    background: var(--border-color);
}

.category-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-title h3 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: capitalize;
}

.category-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    background: var(--primary-light);
    color: var(--primary-color);
    font-weight: 500;
}

.category-toggle {
    transition: transform 0.2s ease;
}

.category-toggle.collapsed {
    transform: rotate(-90deg);
}

.category-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-left: 0.5rem;
}

.category-items.hidden {
    display: none;
}

/* Checklist Item */
.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.checklist-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.checklist-item.completed {
    background: var(--success-light);
    border-color: var(--success-color);
}

.checklist-item.na {
    background: var(--neutral-light);
    border-color: var(--neutral-color);
    opacity: 0.7;
}

.item-status {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.status-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.status-btn:hover {
    border-color: var(--primary-color);
}

.status-btn.check:hover {
    background: var(--success-light);
    border-color: var(--success-color);
}

.status-btn.na-btn:hover {
    background: var(--neutral-light);
    border-color: var(--neutral-color);
}

.status-btn.active.check {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.status-btn.active.na-btn {
    background: var(--neutral-color);
    border-color: var(--neutral-color);
    color: white;
}

.item-content {
    flex: 1;
    min-width: 0;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.item-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.item-badges {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

.badge {
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-level-a {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-level-aa {
    background: #fef3c7;
    color: #d97706;
}

.badge-level-aaa {
    background: #fce7f3;
    color: #be185d;
}

.badge-custom {
    background: #e0e7ff;
    color: #4f46e5;
}

.item-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.item-actions .btn-small {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.item-delete {
    margin-left: auto;
}

.item-notes {
    margin-top: 0.75rem;
}

.item-notes textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
}

.item-notes textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Report Section */
.report-section {
    margin-top: 1.5rem;
}

.report-content {
    margin-bottom: 1.5rem;
}

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

.report-stat {
    background: var(--bg-tertiary);
    padding: 1.25rem;
    border-radius: var(--border-radius-sm);
    text-align: center;
}

.report-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.report-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.report-categories {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.report-category {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
}

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

.report-category-name {
    font-weight: 600;
    text-transform: capitalize;
}

.report-category-progress {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.report-category-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.report-category-fill {
    height: 100%;
    background: var(--success-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.report-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: var(--bg-tertiary);
    padding: 1.5rem;
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-content p {
    font-size: 0.875rem;
    margin: 0;
}

.powered-by a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.powered-by a:hover {
    color: #93c5fd;
    text-decoration: underline;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 0.9375rem;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 1rem;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal.show .modal-content {
    transform: scale(1);
}

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

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .title-group h1 {
        font-size: 1.25rem;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

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

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

    .checklist-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-controls {
        width: 100%;
    }

    .search-box {
        flex: 1;
    }

    .search-box input {
        width: 100%;
    }

    .search-box input:focus {
        width: 100%;
    }

    .filter-select {
        flex: 1;
    }

    .checklist-item {
        flex-direction: column;
    }

    .item-status {
        flex-direction: row;
    }

    .report-actions {
        flex-direction: column;
    }

    .report-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }

    .progress-card,
    .config-card,
    .custom-card,
    .report-card {
        padding: 1rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .btn-large {
        padding: 0.75rem 1.5rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .progress-percentage {
        font-size: 1.25rem;
    }
}

/* Print Styles */
@media print {
    .header-actions,
    .config-section,
    .custom-section,
    .filter-controls,
    .item-actions,
    .report-actions,
    .btn {
        display: none !important;
    }

    .app-container {
        min-height: auto;
    }

    .header {
        position: static;
        box-shadow: none;
    }

    .checklist-container {
        max-height: none;
        overflow: visible;
    }

    .checklist-item {
        break-inside: avoid;
    }

    .category-group {
        break-inside: avoid;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #000;
    }

    .btn {
        border: 2px solid currentColor;
    }
}
