/* ===================================
   MODERN UI ENHANCEMENTS
   =================================== */

/* Global Styling */
:root {
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* Cards - Tournament Cards */
.tournament-card {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.tournament-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--color-primary);
}

.tournament-card-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #f3f4f6 0%, #fffbeb 100%);
}

.tournament-card-body {
    padding: 1rem;
    flex: 1;
}

.tournament-card-footer {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    gap: 0.5rem;
}

/* Dark Mode Cards */
.dark .tournament-card {
    background: #1f2937;
    border-color: #374151;
}

.dark .tournament-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.dark .tournament-card-header {
    background: linear-gradient(135deg, #2d3748 0%, #374151 100%);
    border-color: #374151;
}

.dark .tournament-card-footer {
    background: #1f2937;
    border-color: #374151;
}

/* Tournament Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-past {
    background: #f3f4f6;
    color: #4b5563;
}

.status-full {
    background: #fee2e2;
    color: #7f1d1d;
}

.status-waitlist {
    background: #fef3c7;
    color: #92400e;
}

.dark .status-active {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.dark .status-past {
    background: rgba(75, 85, 99, 0.2);
    color: #d1d5db;
}

.dark .status-full {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.dark .status-waitlist {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.dark .info-label {
    color: #9ca3af;
}

.info-value {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.dark .info-value {
    color: #f3f4f6;
}

/* Modern Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #111827;
}

.dark .form-label {
    color: #f3f4f6;
}

.form-input,
.input {
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: #111827;
    transition: all 0.2s;
}

.form-input:focus,
.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.dark .form-input,
.dark .input {
    background: #1f2937;
    border-color: #374151;
    color: #f3f4f6;
}

.dark .form-input:focus,
.dark .input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-select,
select.input {
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: #111827;
    cursor: pointer;
    transition: all 0.2s;
}

.form-select:focus,
select.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.dark .form-select,
.dark select.input {
    background: #1f2937;
    border-color: #374151;
    color: #f3f4f6;
}

/* Button Styles */
.button-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: #f3f4f6;
    color: #374151;
}

.btn-icon:hover {
    background: #e5e7eb;
    transform: scale(1.05);
}

.dark .btn-icon {
    background: #374151;
    color: #d1d5db;
}

.dark .btn-icon:hover {
    background: #4b5563;
}

/* Modal Enhancements */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.dark .modal-header {
    border-color: #374151;
}

.modal-body {
    padding: 1.5rem;
}

.desc-collapse {
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.desc-collapse.collapsed {
    max-height: 38rem;
}

.desc-toggle-button {
    display: block;
    margin: 0.75rem auto 0;
    padding: 0.35rem 0.75rem;
    text-align: center;
    color: #2563eb;
    font-weight: 700;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.desc-toggle-button:hover {
    color: #1d4ed8;
    transform: scale(1.02);
}

.dark .desc-toggle-button {
    color: #60a5fa;
}

.dark .desc-toggle-button:hover {
    color: #93c5fd;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.dark .modal-footer {
    background: #111827;
    border-color: #374151;
}

/* Loading State */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: #d1d5db;
}

.dark .empty-state-icon {
    color: #4b5563;
}

/* Toast Notifications */
.toast {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(400px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Input Error States */
.input.error,
.form-input.error,
.form-select.error {
    border-color: #ef4444;
}

.input.error:focus,
.form-input.error:focus,
.form-select.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.input.valid,
.form-input.valid,
.form-select.valid {
    border-color: #10b981;
}

.input.valid:focus,
.form-input.valid:focus,
.form-select.valid:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Responsive Grid */
@media (max-width: 640px) {
    .tournament-card {
        border-radius: 8px;
    }
    
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .button-group button {
        width: 100%;
    }
}

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

/* Focus indication */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Utility Classes */
.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.gap-x-2 {
    column-gap: 0.5rem;
}

.gap-y-2 {
    row-gap: 0.5rem;
}

/* Statistics Cards Animation */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card {
    animation: slideUp 0.5s ease-out;
}

/* Smooth scrolling */
.scrollable {
    scroll-behavior: smooth;
    overflow-y: auto;
}

/* Spinner */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Table Improvements */
table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: #f9fafb;
    padding: 0.875rem;
    text-align: left;
    font-weight: 600;
    color: #111827;
    border-bottom: 2px solid #e5e7eb;
}

.dark table th {
    background: #111827;
    color: #f3f4f6;
    border-bottom-color: #374151;
}

table td {
    padding: 0.875rem;
    border-bottom: 1px solid #e5e7eb;
}

.dark table td {
    border-bottom-color: #374151;
}

table tbody tr:hover {
    background: #f9fafb;
}

.dark table tbody tr:hover {
    background: #111827;
}

/* Divider */
.divider {
    height: 1px;
    background: #e5e7eb;
    margin: 1rem 0;
}

.dark .divider {
    background: #374151;
}

/* Card Grid Layout */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
}

/* Accessibility - Visually Hidden Text */
.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;
}
