/* Reset dan Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.hero {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.hero h1 {
    font-size: 3em;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    color: white;
}

.header h1 {
    font-size: 2em;
    font-weight: 700;
}

/* Main Actions */
.main-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.action-card {
    background: white;
    padding: 40px 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.action-card:hover {
    transform: translateY(-5px);
}

.card-icon {
    font-size: 3em;
    margin-bottom: 20px;
}

.action-card h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.5em;
}

.action-card p {
    color: #666;
    margin-bottom: 25px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: #4361ee;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #3a56d4;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #7209b7;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5e08a0;
    transform: translateY(-2px);
}

.btn-danger {
    background: #f72585;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #e11574;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-outline:hover {
    background: rgba(255,255,255,0.1);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.back-btn {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* Share Container */
.share-container {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.setup-panel {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #4361ee;
}

/* Preview Container */
.preview-container {
    width: 100%;
    height: 300px;
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
    margin: 25px 0;
    border: 2px dashed #dee2e6;
    position: relative;
}

#previewVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

.no-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.preview-placeholder {
    text-align: center;
    color: #6c757d;
}

.placeholder-icon {
    font-size: 4em;
    margin-bottom: 15px;
    display: block;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    margin: 25px 0;
    justify-content: center;
}

/* Stream Info */
.stream-info {
    background: #d4edda;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #28a745;
    text-align: center;
}

.stream-info h3 {
    color: #155724;
    margin-bottom: 10px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9em;
    color: #6c757d;
}

.stat-value {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

.live {
    color: #dc3545;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Viewer Container */
.viewer-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stream-count {
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    color: white;
}

/* Streams Grid */
.streams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.stream-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.stream-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.stream-card-header {
    background: #4361ee;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stream-title {
    font-weight: 600;
    font-size: 1.1em;
}

.stream-meta {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
    opacity: 0.9;
}

.stream-preview {
    height: 200px;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    position: relative;
}

.preview-placeholder {
    text-align: center;
}

.preview-placeholder .placeholder-icon {
    font-size: 3em;
    margin-bottom: 10px;
    color: rgba(255,255,255,0.7);
}

.stream-info-footer {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.streamer-info {
    font-size: 0.9em;
    color: #666;
}

.viewer-count {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
    color: #666;
}

/* No Streams */
.no-streams {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
}

.empty-state {
    color: #666;
}

.empty-icon {
    font-size: 4em;
    margin-bottom: 20px;
    display: block;
    opacity: 0.5;
}

.empty-state h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.8em;
}

.empty-state p {
    color: #666;
    max-width: 500px;
    margin: 0 auto 20px;
}

.hint {
    margin-top: 10px;
    font-size: 0.9em;
    opacity: 0.8;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    color: #4cc9f0;
}

.loading-spinner i {
    font-size: 1.2rem;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
}

/* Grid View */
.grid-view {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Fullscreen Video View */
.video-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1000;
}

.video-view:not(.hidden) {
    display: block;
}

.video-view.hidden {
    display: none;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

/* Waiting Message for Fullscreen */
.waiting-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    text-align: center;
    z-index: 10;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.waiting-message p {
    font-size: 1.2em;
    margin: 0;
    opacity: 0.9;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Minimal Video Controls */
.video-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1001;
}

.video-view:hover .video-controls {
    opacity: 1;
}

.control-btn {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2em;
    backdrop-filter: blur(10px);
}

.control-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.control-icon {
    font-size: 1.1em;
}

/* Hide cursor after inactivity */
.video-view {
    cursor: none;
}

.video-view:hover {
    cursor: default;
}

/* Animation for video appearance */
@keyframes videoFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#remoteVideo {
    animation: videoFadeIn 0.5s ease-in;
}

/* Modal Styles (Backup) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px 25px;
    background: #4361ee;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.modal-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.video-container {
    position: relative;
    background: #000;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fullscreen Styles */
.modal.fullscreen {
    padding: 0;
}

.modal.fullscreen .modal-content {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    width: 100%;
    height: 100%;
}

.modal.fullscreen .video-container {
    height: calc(100vh - 80px);
}

.modal.fullscreen #remoteVideo {
    max-height: 100%;
}

.fullscreen-icon {
    font-size: 1.2em;
}

/* Close Button */
.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Status Styles */
.status {
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9em;
}

.status.connected {
    background: #d4edda;
    color: #155724;
}

.status:not(.connected) {
    background: #fff3cd;
    color: #856404;
}

.stream-status {
    font-size: 0.9em;
    opacity: 0.8;
}

.stream-status.connected {
    color: #4cc9f0;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Connection Status */
.connection-status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.connection-status.connected {
    background: rgba(76, 201, 240, 0.2);
    color: #4cc9f0;
    border: 1px solid #4cc9f0;
}

.connection-status.disconnected {
    background: rgba(247, 37, 133, 0.2);
    color: #f72585;
    border: 1px solid #f72585;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    background: #212529;
    color: white;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: #4cc9f0;
}

.toast.error {
    background: #f72585;
}

.toast.info {
    background: #4361ee;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .hero h1 {
        font-size: 2em;
    }
    
    .header h1 {
        font-size: 1.5em;
    }
    
    .main-actions {
        grid-template-columns: 1fr;
        gap: 20px;
        margin: 20px 0;
    }
    
    .action-card {
        padding: 30px 20px;
    }
    
    .share-container {
        padding: 20px;
    }
    
    .preview-container {
        height: 250px;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .streams-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stream-preview {
        height: 180px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .video-controls {
        top: 15px;
        right: 15px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    .waiting-message p {
        font-size: 1em;
    }
    
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .video-container {
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 40px 15px;
    }
    
    .hero h1 {
        font-size: 1.8em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .action-card {
        padding: 25px 15px;
    }
    
    .card-icon {
        font-size: 2.5em;
    }
    
    .stream-card-header {
        padding: 12px 15px;
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .stream-info-footer {
        padding: 12px 15px;
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .video-controls {
        top: 10px;
        right: 10px;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 1em;
    }
    
    .modal-header h3 {
        font-size: 1.1em;
    }
    
    .video-container {
        min-height: 250px;
    }
    
    .waiting-message p {
        font-size: 0.9em;
    }
    
    .spinner {
        width: 40px;
        height: 40px;
    }
}

/* Print Styles */
@media print {
    .video-view,
    .modal,
    .video-controls,
    .controls {
        display: none !important;
    }
    
    .grid-view {
        background: white !important;
        color: black !important;
    }
    
    .stream-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .stream-card {
        border: 2px solid currentColor;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .stream-card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .action-card,
    .share-container,
    .viewer-container,
    .stream-card,
    .stream-info-footer {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .action-card h2,
    .stream-title {
        color: #e2e8f0;
    }
    
    .action-card p {
        color: #a0aec0;
    }
    
    .form-group input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .form-group input:focus {
        border-color: #63b3ed;
    }
}

/* Accessibility */
@media (hover: hover) {
    .stream-card:hover .stream-title {
        text-decoration: underline;
    }
}

/* Focus styles for accessibility */
.btn:focus,
.control-btn:focus,
.close-btn:focus,
.stream-card:focus {
    outline: 2px solid #4361ee;
    outline-offset: 2px;
}

/* Selection styles */
::selection {
    background: #4361ee;
    color: white;
}

::-moz-selection {
    background: #4361ee;
    color: white;
}