
:root {
    --primary-color: #007bff;
    --primary-hover-color: #0056b3;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-color: #343a40;
    --border-color: #dee2e6;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --border-radius: 0.375rem;
    --box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex-grow: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* --- Navbar --- */
.navbar {
    background-color: var(--surface-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--secondary-color);
    font-weight: 500;
    transition: color 0.2s ease-in-out;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
}

.nav-user button {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
}

/* --- Login Page --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-form {
    background: var(--surface-color);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-form h1 {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background-color: white;
}
.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    text-align: center;
}

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

.btn:disabled {
    background-color: #a0c7f0;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--secondary-color);
}
.btn-secondary:hover {
    background-color: #5a6268;
}

.error-message {
    color: var(--danger-color);
    margin-top: 1rem;
}


/* --- Dashboard & Generic Page Styles --- */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.page-header h1 {
    font-size: 2.5rem;
}

.page-header p {
    font-size: 1.1rem;
    color: var(--secondary-color);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 1.5rem;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.card ul {
    list-style: none;
}

.card li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.card li:last-child {
    border-bottom: none;
}

/* --- Filters --- */
.filters {
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--secondary-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.filter-btn:hover {
    background-color: #e9ecef;
}

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


/* --- Loading Spinner --- */
.loading-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -25px;
    margin-top: -25px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.modal-content {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 700px; /* Increased max-width for manage team */
    position: relative;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
}

.modal-body {
    overflow-y: auto;
}

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

.tournament-details-list {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0.75rem 1.5rem;
}

.tournament-details-list dt {
    font-weight: bold;
    color: var(--secondary-color);
}

.tournament-details-list dd {
    margin: 0;
}

/* --- Chat Component --- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 60vh;
    max-height: 500px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

.message-sender {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1.25rem;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-top: 0.25rem;
}

.message.sent {
    align-self: flex-end;
    align-items: flex-end;
}
.message.sent .message-bubble {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.received {
    align-self: flex-start;
    align-items: flex-start;
}
.message.received .message-bubble {
    background-color: #e9ecef;
    color: var(--text-color);
    border-bottom-left-radius: 0.25rem;
}

.chat-input-form {
    display: flex;
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
}

.chat-input-form input {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    font-size: 1rem;
    margin-right: 0.5rem;
}

.chat-input-form button {
    padding: 0.75rem 1.25rem;
}

/* --- Manage Team Modal --- */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.modal-tab {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1.1rem;
    color: var(--secondary-color);
    border-bottom: 3px solid transparent;
}

.modal-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.user-list {
    list-style: none;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.5rem;
}

.user-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
}

.user-list-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.favorite-star {
    cursor: pointer;
    font-size: 1.5rem;
    color: #ccc;
    margin-right: 1rem;
}

.favorite-star.favorited {
    color: #ffc107;
}

.user-info span {
    display: block;
}
.user-info .username {
    font-weight: bold;
}
.user-info .engagements {
    font-size: 0.8rem;
    color: var(--secondary-color);
}

.guest-indicator {
    font-style: italic;
    color: var(--secondary-color);
    margin-left: 0.5rem;
    font-size: 0.9rem;
}

.form-divider {
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    border: 0;
    border-top: 1px solid var(--border-color);
}

/* --- Create Tournament Modal --- */
.file-analysis-section {
    background-color: #f8f9fa;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.file-analysis-section p {
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.file-preview {
    margin-top: 1rem;
    font-weight: 500;
}

.analysis-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-weight: bold;
    color: var(--primary-color);
}
.analysis-status .spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 123, 255, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* --- Tournament Documents --- */
.documents-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.documents-section h3, .documents-section h4 {
    margin-bottom: 1rem;
}

.documents-list {
    list-style: none;
    margin-bottom: 1.5rem;
}

.document-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
}

.document-item:not(:last-child) {
    margin-bottom: 0.5rem;
}

.document-item button {
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
}
.document-item button:hover {
    background-color: #5a6268;
}

.upload-section input[type="file"] {
    margin-right: 1rem;
    margin-bottom: 0.5rem; /* For mobile stacking */
}