/* CSS Variables - Theme Colors */
:root {
    --primary-color: #1a73e8;
    --secondary-color: #5f6368;
    --sidebar-color: #202124;
    --header-color: #303134;
    --background-color: #171717;
    --text-color: #e8eaed;
    --accent-color: #8ab4f8;
    --border-color: #3c4043;
    --card-color: #292a2d;
    --success-color: #34a853;
    --warning-color: #fbbc04;
    --danger-color: #ea4335;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.4);
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 260px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.content-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background-color: var(--sidebar-color);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    max-width: 100%;
    max-height: 50px;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-color);
    opacity: 0.8;
    transition: all 0.2s;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    opacity: 1;
    text-decoration: none;
}

.nav-link.active {
    background-color: rgba(var(--primary-color), 0.1);
    color: var(--accent-color);
    opacity: 1;
    border-right: 3px solid var(--primary-color);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 1rem 0;
}

.nav-label {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary-color);
}

/* Header */
.main-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background-color: var(--header-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-color);
    transition: transform 0.2s;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 500;
    flex: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-weight: 500;
}

.user-role {
    font-size: 0.75rem;
    color: var(--secondary-color);
    text-transform: capitalize;
}

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

/* Video Player */
.video-player-container {
    position: relative;
    background-color: #000;
    aspect-ratio: 16 / 9;
    max-height: 300px;
}

.video-frame {
    width: 100%;
    height: 100%;
}

.video-toggle {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
    opacity: 0;
    transition: opacity 0.2s;
}

.video-player-container:hover .video-toggle {
    opacity: 1;
}

.video-toggle svg {
    width: 20px;
    height: 20px;
}

.video-player-container.minimized {
    max-height: 0;
    overflow: hidden;
}

.video-rtsp-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

/* Cards */
.card {
    background-color: var(--card-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Dashboard */
.dashboard {
    max-width: 1200px;
}

.welcome-section {
    margin-bottom: 2rem;
}

.welcome-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

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

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background-color: var(--card-color);
    border-radius: 8px;
}

.stat-icon {
    color: var(--primary-color);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--secondary-color);
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: background-color 0.2s;
}

.quick-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.quick-link svg {
    color: var(--primary-color);
}

.quick-link span {
    font-size: 0.875rem;
    text-align: center;
}

.recent-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-message {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}

.recent-message .message-author {
    font-weight: 500;
    font-size: 0.875rem;
}

.recent-message .message-preview {
    flex: 1;
    font-size: 0.875rem;
    color: var(--secondary-color);
}

.recent-message .message-time {
    font-size: 0.75rem;
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--card-color);
    border-radius: 8px 8px 0 0;
}

.chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--secondary-color);
}

.chat-message {
    max-width: 70%;
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    align-self: flex-start;
}

.chat-message.own-message {
    align-self: flex-end;
    background-color: var(--primary-color);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.message-author {
    font-weight: 500;
    font-size: 0.875rem;
}

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

.own-message .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-body {
    word-wrap: break-word;
}

.chat-form {
    background-color: var(--card-color);
    padding: 1rem;
    border-radius: 0 0 8px 8px;
    border-top: 1px solid var(--border-color);
}

.chat-input-group {
    display: flex;
    gap: 0.5rem;
}

.chat-input-group textarea {
    flex: 1;
    padding: 0.75rem 1rem;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-color);
    font-size: 1rem;
    resize: none;
    max-height: 120px;
}

.chat-input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-input-group button {
    padding: 0.75rem;
    border-radius: 50%;
    width: 44px;
    height: 44px;
}

.chat-admin-actions {
    margin-top: 1rem;
    text-align: right;
}

/* Files */
.files-container {
    max-width: 1200px;
}

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

.section-header h2 {
    font-size: 1.25rem;
}

.upload-form-container {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background-color: var(--card-color);
    border-radius: 8px;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
}

.upload-placeholder svg {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.upload-placeholder p {
    margin-bottom: 0.5rem;
}

.file-input {
    display: none;
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.2s;
}

.progress-text {
    font-size: 0.875rem;
    min-width: 40px;
    text-align: right;
}

.files-list {
    background-color: var(--card-color);
    border-radius: 8px;
    overflow: hidden;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--secondary-color);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.data-table .actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.file-icon {
    margin-right: 0.5rem;
}

/* Gallery */
.gallery-container {
    max-width: 1400px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--card-color);
}

.gallery-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.gallery-item-title {
    font-weight: 500;
}

.gallery-item-author {
    font-size: 0.875rem;
    color: var(--secondary-color);
}

.gallery-item-date {
    font-size: 0.75rem;
    color: var(--secondary-color);
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    width: 48px;
    height: 48px;
    line-height: 1;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
}

/* Members */
.members-container {
    max-width: 1200px;
}

.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.member-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background-color: var(--card-color);
    border-radius: 8px;
    text-align: center;
}

.member-card.timed-out {
    opacity: 0.6;
}

.member-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.member-avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

.member-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.member-name {
    font-weight: 600;
}

.member-role {
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.member-email,
.member-phone {
    font-size: 0.875rem;
    color: var(--secondary-color);
}

.member-status {
    padding: 0.5rem 1rem;
    background-color: rgba(234, 67, 53, 0.2);
    color: var(--danger-color);
    border-radius: 4px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.member-cell {
    display: flex;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

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

.btn-primary:hover {
    background-color: #1557b0;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

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

.btn-danger:hover {
    background-color: #c5221f;
}

.btn-warning {
    background-color: var(--warning-color);
    color: #000;
}

.btn-warning:hover {
    background-color: #e5a800;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}

.badge-success {
    background-color: rgba(52, 168, 83, 0.2);
    color: var(--success-color);
}

.badge-danger {
    background-color: rgba(234, 67, 53, 0.2);
    color: var(--danger-color);
}

.badge-warning {
    background-color: rgba(251, 188, 4, 0.2);
    color: var(--warning-color);
}

.badge-info {
    background-color: rgba(26, 115, 232, 0.2);
    color: var(--accent-color);
}

.badge-secondary {
    background-color: rgba(95, 99, 104, 0.2);
    color: var(--secondary-color);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: rgba(52, 168, 83, 0.2);
    color: var(--success-color);
    border: 1px solid rgba(52, 168, 83, 0.3);
}

.alert-error {
    background-color: rgba(234, 67, 53, 0.2);
    color: var(--danger-color);
    border: 1px solid rgba(234, 67, 53, 0.3);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.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 1rem;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.form-row .form-group {
    margin-bottom: 0;
}

.flex-grow {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Template Settings */
.settings-form {
    max-width: 800px;
}

.settings-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: var(--card-color);
    border-radius: 8px;
}

.settings-section h3 {
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.color-input-group {
    display: flex;
    gap: 0.5rem;
}

.color-input-group input[type="color"] {
    width: 50px;
    height: 40px;
    padding: 0;
    border: none;
    cursor: pointer;
}

.color-input-group .color-text {
    flex: 1;
    padding: 0.5rem;
}

.logo-upload {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.current-logo {
    max-height: 50px;
}

/* Video Settings */
.video-settings-container {
    max-width: 1000px;
}

.video-url-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-preview {
    aspect-ratio: 16 / 9;
    max-width: 600px;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
}

.video-preview iframe,
.video-preview video {
    width: 100%;
    height: 100%;
}

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

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-box {
    background-color: var(--card-color);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    display: block;
    max-width: 150px;
    margin: 0 auto 2rem;
}

.login-title {
    text-align: center;
    margin-bottom: 2rem;
}

.login-form {
    margin-bottom: 1rem;
}

.login-footer {
    text-align: center;
    font-size: 0.875rem;
    color: var(--secondary-color);
}

/* Utilities */
.text-muted {
    color: var(--secondary-color);
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

/* File Category Tabs */
.file-category-tabs {
    display: flex;
    gap: 0.25rem;
    background-color: var(--card-color);
    border-radius: 8px;
    padding: 0.25rem;
}

.tab-link {
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0.7;
    transition: all 0.2s;
}

.tab-link:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.05);
    text-decoration: none;
}

.tab-link.active {
    background-color: var(--primary-color);
    color: white;
    opacity: 1;
}

/* Public Pages Layout */
.public-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.public-container {
    width: 100%;
    max-width: 600px;
}

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

.public-logo {
    max-width: 200px;
    max-height: 60px;
}

.public-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.public-card {
    background-color: var(--card-color);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.public-card h2 {
    margin-bottom: 0.5rem;
}

/* Agreement Styles */
.agreement-body {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    line-height: 1.7;
}

.agreement-discount-info {
    background-color: rgba(52, 168, 83, 0.1);
    border: 1px solid rgba(52, 168, 83, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .header-actions .user-info {
        display: none;
    }

    .chat-message {
        max-width: 85%;
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }

    .form-row {
        flex-direction: column;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .content-area {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .section-header .btn {
        width: 100%;
    }

    .file-category-tabs {
        flex-wrap: wrap;
    }

    .tab-link {
        flex: 1;
        text-align: center;
        min-width: 0;
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .public-container {
        max-width: 100%;
    }
}
