/* Enhanced Styles for New Features */

/* Toast Enhancements */
.toast {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 250px;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-show {
    transform: translateY(0);
    opacity: 1;
}

.toast-hide {
    transform: translateY(-20px);
    opacity: 0;
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-message {
    flex: 1;
}

.toast-success {
    border-left: 3px solid #22c55e;
}

.toast-error {
    border-left: 3px solid #ef4444;
}

.toast-warning {
    border-left: 3px solid #f59e0b;
}

.toast-info {
    border-left: 3px solid #3b82f6;
}

/* Stats Panel */
.stats-panel {
    max-width: 700px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition-premium);
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary-light);
    margin-bottom: 0.3rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stat-card.actionable {
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.stat-card.actionable:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-5px);
}

.stat-card.actionable:active {
    transform: translateY(-2px) scale(0.98);
}

.stat-card .stat-action-hint {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    font-size: 0.7rem;
    color: var(--primary-light);
    opacity: 0;
    transition: all 0.3s ease;
    transform: translateY(10px);
}

.stat-card.actionable:hover .stat-action-hint {
    opacity: 0.8;
    transform: translateY(0);
}

.stats-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.stats-section h4 {
    margin-bottom: 1rem;
    color: var(--primary-light);
    font-size: 1rem;
}

/* Mastery Distribution Chart */
.mastery-distribution {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.mastery-bar {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    height: 40px;
    overflow: hidden;
}

.bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mastery-bar[data-level="1"] .bar-fill {
    background: linear-gradient(90deg, #94a3b8, #cbd5e1);
}

.mastery-bar[data-level="2"] .bar-fill {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.mastery-bar[data-level="3"] .bar-fill {
    background: linear-gradient(90deg, #6366f1, #818cf8);
}

.mastery-bar[data-level="4"] .bar-fill {
    background: linear-gradient(90deg, #eab308, #facc15);
}

.bar-label {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 1rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: white;
}

.bar-count {
    margin-left: auto;
}

/* Study Plan */
#study-plan {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.plan-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.plan-icon {
    font-size: 1.5rem;
}

.plan-text {
    flex: 1;
    color: var(--text-muted);
}

.plan-text strong {
    color: var(--primary-light);
}

.plan-item.actionable {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid transparent;
}

.plan-item.actionable:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateX(8px);
}

.plan-item.actionable:active {
    transform: scale(0.98) translateX(8px);
}

.plan-action-hint {
    font-size: 0.75rem;
    color: var(--primary-light);
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    font-weight: 500;
}

.plan-item.actionable:hover .plan-action-hint {
    opacity: 0.8;
    transform: translateX(0);
}

#due-count {
    color: #818cf8;
    font-size: 1.1rem;
    text-shadow: 0 0 10px rgba(129, 140, 248, 0.3);
}

.plan-item.actionable:hover #due-count {
    animation: pulseSmall 1s infinite;
}

@keyframes pulseSmall {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Data Actions */
.data-actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.glass-btn.danger {
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.glass-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

/* Custom Word Panel */
.custom-word-panel {
    max-width: 650px;
    padding: 2.5rem;
}

.modal-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.8rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.modal-tabs::-webkit-scrollbar {
    display: none;
}

.modal-tabs .tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.8rem 1.4rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-tabs .tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.modal-tabs .tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: slideInUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group-row,
.dual-input {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    margin-bottom: 0.5rem;
}

.custom-word-panel textarea,
.custom-word-panel input[type="text"] {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: var(--radius-md);
    color: white !important;
    padding: 1rem !important;
    width: 100%;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.custom-word-panel textarea:focus,
.custom-word-panel input[type="text"]:focus {
    border-color: var(--primary) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.section-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1.5rem;
    opacity: 0.7;
    line-height: 1.5;
}

.tab-header {
    margin-bottom: 1.5rem;
}

.tab-header h3 {
    margin-bottom: 0.5rem;
}

.tab-header .section-hint {
    margin-top: 0.5rem;
}

.bulk-stats {
    margin: 1.5rem 0;
}

.stats-badge {
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-badge.success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.stats-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.stats-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    padding: 0.5rem;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.custom-words-list {
    max-height: 450px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    padding-right: 0.5rem;
}

.custom-words-list::-webkit-scrollbar {
    width: 6px;
}

.custom-words-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.custom-word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

.custom-word-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary-light);
    transform: translateX(5px);
}

.custom-word-item .word-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.custom-word-item .word-info strong {
    color: var(--primary-light);
    font-size: 1.1rem;
}

.custom-word-item .word-info span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.delete-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
    transform: scale(1.1);
}

.svg-generation-options {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.svg-preview {
    margin-top: 1rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.svg-preview svg {
    max-width: 100%;
    max-height: 150px;
}

/* Keyboard Focus Styles */
.card-container:focus {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
    border-radius: var(--radius-lg);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ARIA Live Region */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .data-actions {
        flex-direction: column;
    }

    .data-actions .glass-btn {
        width: 100%;
    }

    .svg-generation-options {
        flex-direction: column;
    }

    .svg-generation-options .glass-btn {
        width: 100%;
    }
}

/* Accessibility - High Contrast Mode */
@media (prefers-contrast: high) {
    .card-face {
        border-width: 2px;
    }

    .glass-btn {
        border-width: 2px;
    }

    .toast {
        border-width: 2px;
    }
}

/* Accessibility - 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 {

    .modal,
    .header-actions,
    .pagination-container,
    #toast-container {
        display: none !important;
    }

    .card {
        break-inside: avoid;
    }
}

/* Utility Classes */
.w-full {
    width: 100%;
}

.mt-4 {
    margin-top: 1rem;
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

/* --- Guide Section Styles --- */
.guide-scrollable {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 1.2rem;
    margin-bottom: 2rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.guide-scrollable::-webkit-scrollbar {
    width: 6px;
}

.guide-scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.guide-section {
    margin-bottom: 2.2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.guide-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.guide-section h4 {
    color: var(--primary-light);
    margin-bottom: 1rem;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.guide-section p {
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.guide-section ul {
    list-style: none;
    padding-left: 0.5rem;
    margin-bottom: 1rem;
}

.guide-section li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.7rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.guide-section li::before {
    content: "➜";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-size: 0.8rem;
    top: 2px;
}

.code-example {
    background: rgba(0, 0, 0, 0.4);
    padding: 1.2rem;
    border-radius: 10px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.85rem;
    color: #818cf8;
    border: 1px solid rgba(129, 140, 248, 0.15);
    overflow-x: auto;
    margin-top: 1rem;
}

.code-example pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    color: #a5b4fc;
}
    word-break: break-all;
    margin-top: 0.8rem;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}


/* ========================================
   Custom Word Manager Guide Enhancements
   ======================================== */

.guide-scrollable {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.guide-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.guide-section:last-child {
    border-bottom: none;
}

.guide-section h4 {
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.guide-section p {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.guide-section ul, .guide-section ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.guide-section li {
    margin-bottom: 0.4rem;
    line-height: 1.5;
}

.code-example {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem;
    margin: 0.75rem 0;
    overflow-x: auto;
}

.code-example pre {
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-services-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.9rem;
}

.ai-services-table th,
.ai-services-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-services-table th {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    font-weight: 600;
}

.ai-services-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Scrollbar styling for guide */
.guide-scrollable::-webkit-scrollbar {
    width: 6px;
}

.guide-scrollable::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.guide-scrollable::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.5);
    border-radius: 3px;
}

.guide-scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.7);
}
