/* =================================
   Component-Specific Styles
   ================================= */

/* Auth Pages (Login/Register) */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    max-width: 450px;
    width: 100%;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .chess-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.auth-header h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--gray);
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--gray);
}

.auth-link a {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--secondary), #2980b9);
    color: var(--white);
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.stat-card h3 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.stat-card p {
    opacity: 0.9;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

/* Tournament List */
.tournament-list {
    display: grid;
    gap: 1.5rem;
}

.tournament-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    transition: var(--transition);
    border-left: 4px solid var(--secondary);
}

.tournament-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.tournament-header h3 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.tournament-code {
    background: var(--primary);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-size: 1.25rem;
    font-weight: bold;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

.tournament-meta {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray);
    font-size: 0.9rem;
}

.meta-item strong {
    color: var(--dark);
}

.tournament-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.tournament-status.active {
    background: var(--success);
    color: var(--white);
}

.tournament-status.pending {
    background: var(--warning);
    color: var(--white);
}

.tournament-status.completed {
    background: var(--gray);
    color: var(--white);
}

.tournament-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Code Display (Big 6-digit code) */
.code-display {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    padding: 3rem;
    border-radius: var(--border-radius);
    text-align: center;
    margin: 2rem 0;
}

.code-display h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.code-value {
    font-size: 4rem;
    font-weight: bold;
    letter-spacing: 0.5rem;
    font-family: 'Courier New', monospace;
    margin: 1rem 0;
}

.code-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

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

.copy-btn:hover {
    background: var(--light);
}

/* Code Input (Join Tournament) */
.code-input {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.digit-input {
    width: 60px;
    height: 70px;
    font-size: 2rem;
    text-align: center;
    border: 3px solid var(--gray-light);
    border-radius: var(--border-radius);
    font-family: 'Courier New', monospace;
    font-weight: bold;
    transition: var(--transition);
}

.digit-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Participants List */
.participants-list {
    list-style: none;
    margin-top: 1rem;
}

.participant-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--light);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

.participant-name {
    font-weight: 600;
    color: var(--dark);
}

.participant-rating {
    color: var(--gray);
}

.participant-status {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    background: var(--success);
    color: var(--white);
}

/* Profile Page */
.profile-header {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: transparent;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    margin: 0 auto 1rem;
    border: 4px solid var(--white);
    overflow: hidden;
    position: relative;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    position: absolute;
    top: 0;
    left: 0;
}

.profile-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.info-item {
    padding: 1rem;
    background: var(--light);
    border-radius: var(--border-radius);
}

.info-label {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.info-value {
    color: var(--dark);
    font-size: 1.2rem;
    font-weight: 600;
}

/* Bracket Visualization */
.bracket {
    overflow-x: auto;
    padding: 2rem 0;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-width: 250px;
}

.bracket-match {
    background: var(--light);
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 2px solid var(--gray-light);
}

.bracket-player {
    padding: 0.5rem;
    background: var(--white);
    border-radius: 4px;
    margin-bottom: 0.25rem;
}

.bracket-player.winner {
    background: var(--success);
    color: var(--white);
    font-weight: bold;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray);
}

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

.empty-state h3 {
    color: var(--dark);
    margin-bottom: 0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .auth-card {
        padding: 2rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .code-value {
        font-size: 2.5rem;
        letter-spacing: 0.25rem;
    }
    
    .digit-input {
        width: 45px;
        height: 55px;
        font-size: 1.5rem;
    }
    
    .tournament-header {
        flex-direction: column;
    }
    
    .tournament-code {
        margin-top: 1rem;
    }
}

/* =================================
   Nove Komponente - Refaktorirano
   ================================= */

/* Toast Notifikacije */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    transition: all 0.3s ease;
    border-left: 4px solid var(--primary);
}

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

.toast.success .toast-icon {
    color: var(--success);
    font-weight: bold;
    font-size: 1.2rem;
}

.toast.error {
    border-left-color: var(--accent);
}

.toast.error .toast-icon {
    color: var(--accent);
    font-weight: bold;
    font-size: 1.2rem;
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.warning .toast-icon {
    color: var(--warning);
    font-weight: bold;
    font-size: 1.2rem;
}

.toast.info {
    border-left-color: var(--secondary);
}

.toast.info .toast-icon {
    color: var(--secondary);
    font-weight: bold;
    font-size: 1.2rem;
}

.toast-message {
    flex: 1;
    color: var(--dark);
}

.toast-close {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gray);
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;
}

.loading-dot {
    width: 12px;
    height: 12px;
    background: var(--white);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-text {
    color: var(--white);
    font-size: 1.1rem;
    font-weight: 500;
}

.loading-spinner-small {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 1rem;
}

.loading-spinner-small .loading-dot {
    width: 8px;
    height: 8px;
    background: var(--secondary);
}

/* Modal Dijalozi */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    opacity: 1;
}

.modal {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

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

.modal-title {
    margin: 0;
    color: var(--primary);
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--gray);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--light);
}

.modal-body {
    padding: 1.5rem;
}

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

.modal-form .form-group {
    margin-bottom: 1rem;
}

/* Kartice */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.empty-card,
.loading-card {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

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

.empty-message {
    color: var(--gray);
    font-size: 1.1rem;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
}

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

.player-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--secondary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.player-info {
    flex: 1;
}

.player-name {
    margin: 0 0 0.25rem 0;
    color: var(--primary);
    font-size: 1.1rem;
}

.player-email,
.player-elo {
    margin: 0;
    color: var(--gray);
    font-size: 0.9rem;
}

/* Error Messages (Validacija) */
.error-message {
    color: var(--accent);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-control.invalid {
    border-color: var(--accent);
    background-color: #fff5f5;
}

.form-control.invalid:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

/* Code Input (6-znamenkasti kod) */
.code-input {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 2rem 0;
}

.digit-input {
    width: 50px;
    height: 60px;
    font-size: 1.8rem;
    text-align: center;
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: bold;
    color: var(--primary);
}

.digit-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.digit-input:disabled {
    background: var(--light);
    cursor: not-allowed;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Notifications Dropdown */
.notifications-container {
    position: relative;
}

.notification-bell {
    position: relative;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: var(--transition);
}

.notification-bell:hover {
    transform: scale(1.1);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.notifications-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 350px;
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.notifications-dropdown.show {
    display: block;
}

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

.notifications-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--dark);
}

.notifications-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--light);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.notification-item:hover {
    background: var(--light);
}

.notification-item.unread {
    background: rgba(76, 175, 80, 0.05);
}

.notification-item.challenge {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.1) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-left: 3px solid var(--warning);
}

.notification-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

.notification-message {
    color: var(--dark);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.notification-time {
    color: var(--gray);
    font-size: 0.75rem;
}

.notification-action {
    margin-top: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.notification-empty {
    padding: 2rem;
    text-align: center;
    color: var(--gray);
}

/* Responsive */
@media (max-width: 768px) {
    .toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
    }
    
    .modal {
        width: 95%;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .code-input {
        gap: 6px;
    }
    
    .digit-input {
        width: 40px;
        height: 50px;
        font-size: 1.5rem;
    }
}
