/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
    /* Colors */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-card-hover: #1f2937;

    /* Accent colors */
    --accent-primary: #3b82f6;
    --accent-primary-light: #60a5fa;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);

    /* Status colors */
    --color-received: #10b981;
    --color-received-bg: rgba(16, 185, 129, 0.15);
    --color-progress: #f59e0b;
    --color-progress-bg: rgba(245, 158, 11, 0.15);
    --color-not-received: #6b7280;
    --color-not-received-bg: rgba(107, 114, 128, 0.15);
    --color-error: #ef4444;

    /* Text colors */
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-radius: 12px;
    --border-radius-lg: 20px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.3);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* ============================================
   Header
   ============================================ */
.header {
    position: relative;
    padding: 3rem 1.5rem 4rem;
    text-align: center;
    overflow: hidden;
}

.header-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    opacity: 0.1;
    z-index: 0;
}

.header-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(59, 130, 246, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 70% 50%, rgba(139, 92, 246, 0.3) 0%, transparent 50%);
    animation: pulse 10s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(1.1) rotate(5deg);
    }
}

.header-content {
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

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

/* ============================================
   Search Section
   ============================================ */
.search-section {
    margin-top: -2rem;
}

.search-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.search-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
}

.search-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.search-card>p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.search-form {
    max-width: 500px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    transition: var(--transition-normal);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.75rem 1rem;
    font-size: 1.25rem;
    font-family: 'Inter', monospace;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-primary);
    outline: none;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
}

.input-wrapper button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent-gradient);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: var(--transition-normal);
}

.input-wrapper button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.input-wrapper button:active {
    transform: translateY(0);
}

.input-wrapper button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.hints {
    margin-top: 1.5rem;
}

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

/* Server Status Indicator */
.server-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    transition: var(--transition-normal);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition-normal);
}

.status-dot.free {
    background: var(--color-received);
    box-shadow: 0 0 8px var(--color-received);
    animation: statusPulse 2s ease-in-out infinite;
}

.status-dot.busy {
    background: var(--color-progress);
    box-shadow: 0 0 8px var(--color-progress);
    animation: statusPulse 1.5s ease-in-out infinite;
}

.status-dot.full {
    background: var(--color-error);
    box-shadow: 0 0 8px var(--color-error);
    animation: statusPulse 1s ease-in-out infinite;
}

.status-text {
    color: var(--text-muted);
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================
   Progress Section
   ============================================ */
.progress-section {
    margin-top: 2rem;
}

.progress-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.progress-header h3 {
    font-size: 1.25rem;
    font-weight: 500;
}

.progress-header h3 span {
    color: var(--accent-primary-light);
    font-weight: 700;
}

.cancel-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--color-error);
    color: var(--color-error);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition-fast);
}

.cancel-btn:hover {
    background: var(--color-error);
    color: white;
}

.progress-bar-container {
    position: relative;
    height: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 12px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.progress-details {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.progress-stat,
.progress-category {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label,
.category-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.stat-value {
    color: var(--accent-primary-light);
    font-weight: 600;
    font-size: 1.125rem;
}

.stat-separator {
    color: var(--text-muted);
}

.category-value {
    color: var(--text-secondary);
    font-size: 0.875rem;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-animation {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.radar {
    width: 80px;
    height: 80px;
    border: 3px solid var(--accent-primary);
    border-radius: 50%;
    position: relative;
    animation: radarPulse 2s ease-out infinite;
    overflow: hidden;
}

.radar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.radar::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-primary), transparent);
    transform-origin: 0% 50%;
    animation: radarSweep 2s linear infinite;
    transform: translateY(-50%);
}

@keyframes radarPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4),
            0 0 0 0 rgba(59, 130, 246, 0.2);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0),
            0 0 0 30px rgba(59, 130, 246, 0);
    }
}

@keyframes radarSweep {
    from {
        transform: translateY(-50%) rotate(0deg);
    }

    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ============================================
   Results Section
   ============================================ */
.results-section {
    margin-top: 2rem;
}

/* Completion Banner */
.completion-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
}

.completion-icon {
    font-size: 1.5rem;
}

.completion-text {
    font-size: 1rem;
    color: var(--text-secondary);
}

.completion-text strong {
    color: var(--color-received);
}

/* Live Stats in Progress Section */
.live-stats {
    margin-top: 1.5rem;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition-normal);
}

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

.stat-icon {
    font-size: 2rem;
}

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

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

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

.stat-received .stat-number {
    color: var(--color-received);
}

.stat-progress .stat-number {
    color: var(--color-progress);
}

.stat-not-received .stat-number {
    color: var(--text-muted);
}

.stat-total .stat-number {
    color: var(--accent-primary-light);
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.filter-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.625rem 1.25rem;
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

/* Results List */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.diploma-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition-normal);
    cursor: pointer;
}

.diploma-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

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

.diploma-card.received .diploma-status-icon {
    background: var(--color-received-bg);
}

.diploma-card.in_progress .diploma-status-icon {
    background: var(--color-progress-bg);
}

.diploma-card.not_received .diploma-status-icon {
    background: var(--color-not-received-bg);
}

.diploma-info {
    flex: 1;
    min-width: 0;
}

.diploma-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.diploma-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.diploma-organization,
.diploma-category {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Diploma Progress Bar */
.diploma-progress-bar-container {
    position: relative;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.diploma-progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.diploma-progress-bar.progress-bar-success {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.diploma-progress-bar.progress-bar-warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.diploma-progress-bar.progress-bar-default {
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.diploma-progress-text {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.diploma-status {
    padding: 0.375rem 0.875rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.diploma-card.received .diploma-status {
    background: var(--color-received-bg);
    color: var(--color-received);
}

.diploma-card.in_progress .diploma-status {
    background: var(--color-progress-bg);
    color: var(--color-progress);
}

.diploma-card.not_received .diploma-status {
    background: var(--color-not-received-bg);
    color: var(--text-muted);
}

/* Status Wrapper with Progress */
.diploma-status-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
}

.diploma-progress-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
}

.diploma-link {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    text-decoration: none;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.diploma-link:hover {
    background: var(--accent-primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

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

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

/* New Search Button */
.new-search {
    text-align: center;
}

.new-search-btn {
    background: transparent;
    border: 2px solid var(--accent-primary);
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    color: var(--accent-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

/* ============================================
   Footer
   ============================================ */
.footer {
    text-align: center;
    padding: 2rem 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer a {
    color: var(--accent-primary-light);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.copyright {
    margin-top: 0.5rem;
    opacity: 0.7;
}

/* ============================================
   Utilities
   ============================================ */

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .header {
        padding: 2rem 1rem 3rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .logo-icon {
        font-size: 2rem;
    }

    .search-card {
        padding: 1.5rem;
    }

    .input-wrapper {
        flex-direction: column;
    }

    .input-wrapper button {
        width: 100%;
        justify-content: center;
    }

    .progress-details {
        flex-direction: column;
    }

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

    .diploma-card {
        flex-wrap: wrap;
    }

    .diploma-info {
        width: 100%;
        order: 2;
    }

    .diploma-status-icon {
        order: 1;
    }

    .diploma-status {
        order: 1;
        margin-left: auto;
    }

    .diploma-link {
        order: 3;
        width: 100%;
        margin-top: 0.5rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .filters {
        justify-content: center;
    }

    .filter-btn {
        flex: 1;
        text-align: center;
        min-width: 45%;
    }
}

/* ============================================
   Loading States
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

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

    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

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