/**
 * Modern CSS for Accounting Glossary - Simple & Modern
 * Clean, responsive, and accessible design
 */

/* CSS Custom Properties - Matching everythingaboutaccounting.info */
:root {
    --ags-primary: #16a085;
    --ags-primary-hover: #138d75;
    --ags-secondary: #2c3e50;
    --ags-accent: #27ae60;
    --ags-white: #ffffff;
    --ags-gray-50: #f8f9fa;
    --ags-gray-100: #ecf0f1;
    --ags-gray-200: #d5dbdb;
    --ags-gray-300: #aeb6bf;
    --ags-gray-600: #5d6d7e;
    --ags-gray-700: #34495e;
    --ags-gray-800: #2c3e50;
    --ags-gray-900: #1b2631;
    
    --ags-font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ags-shadow: 0 2px 8px rgba(44, 62, 80, 0.1);
    --ags-shadow-lg: 0 8px 25px rgba(44, 62, 80, 0.15);
    --ags-radius: 0.375rem;
    --ags-radius-lg: 0.5rem;
    --ags-transition: all 0.2s ease-in-out;
}

/* Dark mode variables */
body.ags-dark-mode {
    --ags-white: #1f2937;
    --ags-gray-50: #111827;
    --ags-gray-100: #1f2937;
    --ags-gray-200: #374151;
    --ags-gray-300: #4b5563;
    --ags-gray-600: #d1d5db;
    --ags-gray-700: #e5e7eb;
    --ags-gray-800: #f3f4f6;
    --ags-gray-900: #f9fafb;
}

/* Base styles */
.ags-glossary-container {
    font-family: var(--ags-font-sans);
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Controls section */
.ags-controls {
    background: var(--ags-white);
    border-radius: var(--ags-radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--ags-gray-200);
    box-shadow: var(--ags-shadow);
}

/* Search input */
#ags-search {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.125rem;
    border: 2px solid var(--ags-gray-300);
    border-radius: var(--ags-radius);
    background: var(--ags-white);
    margin-bottom: 1.5rem;
    transition: var(--ags-transition);
    font-family: var(--ags-font-sans);
}

#ags-search:focus {
    outline: none;
    border-color: var(--ags-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Filter buttons */
.ags-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    justify-content: flex-start;
    margin-bottom: 0;
}

.ags-filter-btn {
    padding: 0.5rem 1rem;
    background: var(--ags-white);
    border: 1px solid var(--ags-gray-300);
    border-radius: 1.5rem;
    color: var(--ags-gray-700);
    font-weight: 500;
    cursor: pointer;
    transition: var(--ags-transition);
    font-size: 0.875rem;
    min-width: 2.5rem;
    text-align: center;
    line-height: 1.2;
}

.ags-filter-btn:hover,
.ags-filter-btn.active {
    background: var(--ags-primary);
    border-color: var(--ags-primary);
    color: var(--ags-white);
    transform: translateY(-1px);
    box-shadow: var(--ags-shadow);
}

/* Dark mode toggle */
.ags-dark-mode-btn {
    display: block;
    margin: 1rem auto 0;
    padding: 0.5rem 1rem;
    background: var(--ags-gray-800);
    color: var(--ags-white);
    border: none;
    border-radius: var(--ags-radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--ags-transition);
}

.ags-dark-mode-btn:hover {
    background: var(--ags-gray-700);
    transform: translateY(-1px);
}

/* Glossary grid */
.ags-glossary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    align-items: start;
}

/* Term cards */
.ags-term-card {
    background: var(--ags-white);
    border: 1px solid var(--ags-gray-200);
    border-radius: var(--ags-radius-lg);
    padding: 1.25rem;
    transition: var(--ags-transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 240px;
    box-shadow: var(--ags-shadow);
}

.ags-term-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ags-primary), var(--ags-accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: var(--ags-transition);
}

.ags-term-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ags-shadow-lg);
    border-color: var(--ags-primary);
}

.ags-term-card:hover::before {
    transform: scaleX(1);
}

/* Term header */
.ags-term-header {
    margin-bottom: 0.75rem;
}

.ags-term-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ags-gray-900);
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
    cursor: help;
    text-decoration: underline;
    text-decoration-color: var(--ags-primary);
    text-underline-offset: 3px;
    transition: var(--ags-transition);
}

.ags-term-title:hover {
    color: var(--ags-primary);
}

/* Term meta section */
.ags-term-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Category badge */
.ags-category-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: var(--ags-gray-100);
    color: var(--ags-gray-700);
    border: 1px solid var(--ags-gray-200);
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Difficulty badges */
.ags-difficulty-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid;
}

.ags-difficulty-beginner {
    background: #d5f4e6;
    color: #27ae60;
    border-color: #a9dfbf;
}

.ags-difficulty-intermediate {
    background: #fdeaa7;
    color: #f39c12;
    border-color: #f7dc6f;
}

.ags-difficulty-advanced {
    background: #fadbd8;
    color: #e74c3c;
    border-color: #f1948a;
}

/* Term definition */
.ags-term-definition {
    color: var(--ags-gray-600);
    line-height: 1.5;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Read more link */
.ags-read-more-link {
    display: inline-flex;
    align-items: center;
    color: var(--ags-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--ags-transition);
    margin-top: auto;
}

.ags-read-more-link:hover {
    color: var(--ags-primary-hover);
    text-decoration: underline;
}

.ags-read-more-link::after {
    content: '→';
    margin-left: 0.5rem;
    transition: var(--ags-transition);
}

.ags-read-more-link:hover::after {
    transform: translateX(2px);
}

/* Modal styles for read more content */
.ags-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.ags-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ags-modal-content {
    background: var(--ags-white);
    border-radius: var(--ags-radius-lg);
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--ags-shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.ags-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ags-gray-900);
    margin: 0;
    flex: 1;
}

.ags-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--ags-gray-600);
    padding: 0.25rem;
    border-radius: var(--ags-radius);
    transition: var(--ags-transition);
}

.ags-modal-close:hover {
    background: var(--ags-gray-100);
    color: var(--ags-gray-900);
}

.ags-modal-body {
    color: var(--ags-gray-700);
    line-height: 1.6;
}

.ags-modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Tooltip styles */
.ags-tooltip {
    position: relative;
    cursor: help;
}

.ags-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ags-gray-800);
    color: var(--ags-white);
    padding: 0.75rem 1rem;
    border-radius: var(--ags-radius);
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 300px;
    white-space: normal;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-5px);
    transition: var(--ags-transition);
    box-shadow: var(--ags-shadow-lg);
    pointer-events: none;
}

.ags-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--ags-gray-800);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: var(--ags-transition);
}

.ags-tooltip:hover::after,
.ags-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Hidden state for filtering */
.ags-term-card.hidden {
    display: none;
}

/* Loading state */
.ags-loading {
    text-align: center;
    padding: 2rem;
    color: var(--ags-gray-600);
}

/* Empty state */
.ags-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ags-gray-600);
}

.ags-empty h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--ags-gray-700);
}

/* Responsive design */
@media (max-width: 768px) {
    .ags-glossary-container {
        padding: 1rem 0.5rem;
    }
    
    .ags-controls {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .ags-glossary-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .ags-term-card {
        padding: 1rem;
        height: 200px;
    }
    
    .ags-term-title {
        font-size: 1.125rem;
    }
    
    .ags-term-meta {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .ags-filters {
        justify-content: flex-start;
        gap: 0.25rem;
    }
    
    .ags-filter-btn {
        min-width: 2rem;
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }
    
    .ags-tooltip::after {
        max-width: 250px;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .ags-glossary-container {
        padding: 0.5rem;
    }
    
    .ags-controls {
        padding: 0.75rem;
    }
    
    .ags-term-card {
        padding: 0.75rem;
        height: 180px;
    }
    
    .ags-term-title {
        font-size: 1rem;
    }
    
    .ags-term-definition {
        font-size: 0.8125rem;
        -webkit-line-clamp: 2;
    }
    
    .ags-filter-btn {
        min-width: 1.75rem;
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    #ags-search {
        font-size: 1rem;
        padding: 0.625rem 0.875rem;
    }
    
    .ags-category-badge,
    .ags-difficulty-badge {
        font-size: 0.6875rem;
        padding: 0.1875rem 0.5rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .ags-filter-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .ags-read-more-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .ags-term-card {
        padding: 1rem;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --ags-primary: #0000ff;
        --ags-gray-600: #000000;
        --ags-gray-700: #000000;
        --ags-gray-800: #000000;
        --ags-gray-900: #000000;
    }
    
    .ags-term-card {
        border-width: 2px;
    }
    
    .ags-filter-btn {
        border-width: 2px;
    }
}

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

/* Print styles */
@media print {
    .ags-controls {
        display: none !important;
    }
    
    .ags-term-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
        margin-bottom: 1rem;
    }
    
    .ags-tooltip::after {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        display: block;
        background: transparent;
        color: #000;
        border: 1px solid #000;
        margin-top: 0.5rem;
        white-space: normal;
    }
    
    .ags-tooltip::before {
        display: none;
    }
}



/* Related terms styles */
.ags-related-terms-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--ags-gray-200);
}

.ags-related-terms-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ags-gray-900);
    margin: 0 0 1rem 0;
}

.ags-related-terms-list {
    display: grid;
    gap: 1rem;
}

.ags-related-term {
    border: 1px solid var(--ags-gray-200);
    border-radius: var(--ags-radius);
    overflow: hidden;
    transition: var(--ags-transition);
}

.ags-related-term:hover {
    border-color: var(--ags-primary);
    box-shadow: var(--ags-shadow);
}

.ags-related-term-link {
    display: block;
    padding: 1rem;
    text-decoration: none;
    color: inherit;
}

.ags-related-term-link:hover {
    text-decoration: none;
}

.ags-related-term-link strong {
    color: var(--ags-primary);
    font-weight: 600;
    display: block;
    margin-bottom: 0.5rem;
}

.ags-related-term-link p {
    color: var(--ags-gray-600);
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 0;
}

/* Responsive modal adjustments */
@media (max-width: 768px) {
    .ags-modal-content {
        margin: 1rem;
        padding: 1.5rem;
        max-height: 90vh;
    }
    
    .ags-modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .ags-modal-close {
        align-self: flex-end;
        margin-top: -0.5rem;
    }
}

