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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 90%;
    max-width: 1200px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: 90vh;
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    text-align: center;
    border-radius: 12px 12px 0 0;
    position: relative;
}

header .header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 5px;
}

header .header-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

header .header-content.collapsed {
    max-height: 0;
    padding: 0;
    margin: 0;
}

.collapse-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.collapse-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
}

.collapse-btn:active {
    transform: scale(0.95);
}

header .subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    margin-bottom: 10px;
}

header .username-display {
    font-size: 0.95em;
    opacity: 0.85;
}

.auth-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.auth-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
}

.auth-btn.logged-in {
    background: rgba(102, 126, 234, 0.8);
    border-color: rgba(102, 126, 234, 1);
}

.auth-btn.logged-in:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.05);
}

/* Navbar Styles */
.navbar {
    background: white;
    border-bottom: 2px solid #e0e0e0;
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.navbar.navbar-compact {
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.nav-home a.nav-logo {
    font-weight: 600;
    color: #333;
    text-decoration: none;
    font-size: 0.95em;
    white-space: nowrap;
    transition: all 0.3s ease;
    background: white;
    border: 2px solid #4CAF50;
    padding: 8px 14px;
    border-radius: 6px;
}

.nav-home a.nav-logo:hover {
    color: white;
    background: #4CAF50;
    border-color: #4CAF50;
}

.nav-menu {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

#navItems {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-dropdown {
    position: relative;
}

.nav-link.dropdown-btn {
    background: white;
    border: 2px solid #667eea;
    color: #333;
    font-size: 0.95em;
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.nav-link.dropdown-btn:hover {
    color: white;
    background: #667eea;
    border-color: #667eea;
}

.nav-link.dropdown-btn:disabled,
.nav-link.dropdown-btn.disabled-btn {
    background: #e0e0e0;
    border: 2px solid #bdbdbd;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.nav-link.dropdown-btn:disabled:hover,
.nav-link.dropdown-btn.disabled-btn:hover {
    color: #999;
    background: #e0e0e0;
    border-color: #bdbdbd;
    transform: none;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    z-index: 100;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.active .dropdown-menu {
    display: block;
}

.nav-dropdown.disabled:hover .dropdown-menu,
.nav-dropdown.disabled.active .dropdown-menu {
    display: none;
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #f5f5f5;
    padding-left: 20px;
    color: #667eea;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 60px 40px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 12px;
    margin-bottom: 40px;
}

.hero h2 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 15px;
}

.hero p {
    font-size: 1.1em;
    color: #666;
    margin-bottom: 30px;
}

.quick-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    text-decoration: none;
    color: #333;
    border: 2px solid #ddd;
    transition: all 0.3s ease;
}

.link-card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-3px);
}

.link-card .card-icon {
    font-size: 2em;
}

.link-card .card-content h3 {
    margin: 0;
    font-size: 1.1em;
    color: #667eea;
}

.link-card .card-content p {
    margin: 5px 0 0 0;
    font-size: 0.9em;
    color: #999;
}

/* Content Section */
.content-section {
    margin-bottom: 40px;
}

.content-section h3 {
    font-size: 1.8em;
    color: #333;
    margin-bottom: 30px;
    text-align: center;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.category-card {
    background: white;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
    padding: 25px;
    transition: all 0.3s ease;
}

.category-card:hover {
    border-color: #667eea;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
    transform: translateY(-5px);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.card-header .card-icon {
    font-size: 1.8em;
}

.card-header h4 {
    margin: 0;
    color: #333;
    font-size: 1.2em;
}

.card-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.card-items li {
    margin-bottom: 10px;
}

.card-items li:last-child {
    margin-bottom: 0;
}

.card-items a {
    display: block;
    padding: 10px 15px;
    color: #667eea;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.95em;
}

.card-items a:hover {
    background: #f0f4ff;
    padding-left: 20px;
    color: #764ba2;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px;
}

.chat-box {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 15px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.message {
    margin-bottom: 15px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    word-break: break-word;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #f0f0f0;
}

.username {
    font-weight: 600;
    color: #667eea;
    font-size: 0.95em;
}

.time {
    font-size: 0.8em;
    color: #999;
}

.message-text {
    color: #333;
    line-height: 1.4;
    font-size: 0.95em;
}

.no-messages {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-style: italic;
}

.loading {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

.message-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.font-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.font-selector label {
    font-weight: 600;
    font-size: 0.9em;
}

.font-selector select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    background: white;
    max-height: 200px;
    overflow-y: auto;
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.send-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
    font-family: inherit;
    resize: none;
    min-height: 80px;
}

#messageInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.char-counter {
    font-size: 0.8em;
    color: #999;
    text-align: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-secondary.active {
    background: #667eea;
    color: white;
}

.status {
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9em;
    min-height: 20px;
}

.status.loading {
    background: #e3f2fd;
    color: #1976d2;
}

.status.success {
    background: #e8f5e9;
    color: #388e3c;
}

.status.error {
    background: #ffebee;
    color: #d32f2f;
}

.status.warning {
    background: #fff3e0;
    color: #f57c00;
}

footer {
    background: #f5f5f5;
    padding: 15px;
    text-align: center;
    font-size: 0.9em;
    color: #666;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

footer p {
    margin: 0;
    flex: 1;
    min-width: 300px;
}

.username-footer {
    text-align: left;
    font-size: 0.85em;
    display: flex;
    flex-direction: column;
    gap: 4px;
    white-space: nowrap;
}

.username-label {
    color: #999;
    font-size: 0.9em;
}

.username-value {
    font-weight: 600;
    color: #667eea;
}

.username-value.duplicate {
    background: linear-gradient(90deg, #ff6b6b, #ffaa39, #667eea, #ff6b6b);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% center;
    }
    50% {
        background-position: 100% center;
    }
}

.toast {
    position: fixed;
    bottom: 100px;
    left: 20px;
    max-width: 350px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    font-size: 0.95em;
    color: #333;
    line-height: 1.5;
    opacity: 0;
    transform: translateX(-400px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    z-index: 1000;
    border-left: 4px solid #667eea;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 2000;
    overflow-y: auto;
    padding: 20px;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 700px;
    overflow: visible;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.modal-close:hover {
    transform: rotate(90deg);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.modal-body p {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 0.95em;
}

.auth-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
    margin-bottom: 15px;
    transition: border-color 0.3s ease;
}

.auth-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-error {
    color: #d32f2f;
    font-size: 0.9em;
    margin-bottom: 10px;
    min-height: 20px;
}

.modal-footer {
    padding: 15px 25px;
    background: #f5f5f5;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #e0e0e0;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        height: 95vh;
        max-width: 100%;
    }

    header {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }

    header .header-top {
        gap: 10px;
    }

    header .subtitle {
        font-size: 0.95em;
    }

    header .username-display {
        font-size: 0.85em;
    }

    .collapse-btn {
        padding: 5px 10px;
        font-size: 0.9em;
    }

    .auth-btn {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 0.85em;
    }

    .navbar {
        padding: 10px 0;
        flex-wrap: wrap;
    }

    .nav-container {
        width: 100%;
        gap: 10px;
    }

    .nav-menu {
        width: 100%;
        gap: 5px;
    }

    .nav-link.dropdown-btn {
        padding: 6px 10px;
        font-size: 0.85em;
    }

    .dropdown-menu {
        min-width: 150px;
        font-size: 0.9em;
    }

    main {
        padding: 12px;
    }

    .message-input-area {
        gap: 8px;
    }

    .font-selector {
        gap: 8px;
    }

    .font-selector label {
        font-size: 0.85em;
        min-width: 45px;
    }

    .font-selector select {
        padding: 6px 8px;
        font-size: 0.85em;
        flex: 1;
    }

    .input-group {
        flex-direction: column;
        gap: 8px;
    }

    .send-area {
        width: 100%;
    }

    #messageInput {
        width: 100%;
        padding: 10px;
        min-height: 70px;
        font-size: 0.9em;
    }

    .btn {
        width: 100%;
        padding: 10px 16px;
        font-size: 0.9em;
    }

    .btn-primary {
        width: 100%;
    }

    .messages-container {
        padding: 12px;
        border-radius: 6px;
    }

    .message {
        padding: 10px;
        margin-bottom: 12px;
        font-size: 0.9em;
    }

    .message-header {
        gap: 8px;
        flex-wrap: wrap;
    }

    .username {
        font-size: 0.9em;
    }

    .time {
        font-size: 0.75em;
    }

    .message-text {
        font-size: 0.9em;
    }

    .char-counter {
        font-size: 0.75em;
    }

    .status {
        font-size: 0.85em;
        padding: 8px;
    }

    .modal-content {
        width: 95%;
        max-width: 100%;
        border-radius: 8px;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-header h2 {
        font-size: 1.3em;
    }

    .modal-body {
        padding: 20px;
        max-height: calc(90vh - 130px);
    }

    .modal-footer {
        padding: 12px 20px;
        gap: 8px;
        flex-direction: column-reverse;
        flex-shrink: 0;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .toast {
        bottom: 80px;
        left: 10px;
        right: 10px;
        max-width: none;
        font-size: 0.9em;
    }

    footer {
        padding: 12px;
        flex-direction: column;
        gap: 12px;
        font-size: 0.85em;
    }

    footer p {
        min-width: auto;
    }

    .username-footer {
        text-align: left;
        font-size: 0.75em;
    }

    .hero {
        padding: 30px 20px;
    }

    .hero h2 {
        font-size: 1.8em;
    }

    .hero p {
        font-size: 1em;
    }

    .quick-links {
        gap: 15px;
    }

    .link-card {
        padding: 15px 20px;
        flex-direction: column;
        text-align: center;
    }

    .categories-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .category-card {
        padding: 20px;
    }

    .card-items a {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .auth-input {
        padding: 10px;
        font-size: 0.9em;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .container {
        border-radius: 8px;
    }

    header {
        padding: 12px;
    }

    header h1 {
        font-size: 1.4em;
    }

    header .header-top {
        flex-direction: column;
        gap: 8px;
    }

    .auth-btn {
        position: static;
        width: 100%;
        margin-top: 10px;
    }

    .navbar {
        padding: 8px 0;
    }

    .nav-link.dropdown-btn {
        padding: 5px 8px;
        font-size: 0.8em;
        flex: 1;
        min-width: auto;
    }

    .dropdown-menu {
        min-width: 120px;
        font-size: 0.8em;
    }

    main {
        padding: 10px;
    }

    .message {
        padding: 8px;
        margin-bottom: 10px;
        font-size: 0.85em;
    }

    .message-header {
        gap: 5px;
    }

    .username {
        font-size: 0.85em;
    }

    .time {
        font-size: 0.7em;
    }

    #messageInput {
        min-height: 60px;
        font-size: 16px;
    }

    .font-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .font-selector select {
        width: 100%;
    }

    .modal-header h2 {
        font-size: 1.2em;
    }

    .modal-body {
        padding: 15px;
    }

    footer {
        padding: 10px;
    }

    footer p {
        font-size: 0.8em;
    }

    .hero h2 {
        font-size: 1.5em;
    }

    .hero p {
        font-size: 0.95em;
    }

    .link-card .card-icon {
        font-size: 1.5em;
    }
}
