/* Reset e base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0a0a;
    color: #ffffff;
    line-height: 1.6;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

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

.login-box {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
}

.logo h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #00d4ff, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo p {
    color: #888;
    margin-bottom: 2rem;
}

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

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

.form-group input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

.login-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(45deg, #00d4ff, #0099cc);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 8px;
    color: #ff6b6b;
    font-size: 0.9rem;
}

.error-message.inline {
    display: block;
    margin: 0 auto;
    max-width: 400px;
    text-align: center;
}

/* Dashboard Page */
.dashboard-page {
    min-height: 100vh;
    background: #0a0a0a;
}

.header {
    background: #080808;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 200;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    background: linear-gradient(45deg, #00d4ff, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.view-switch {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.view-link {
    color: #888;
    text-decoration: none;
    font-weight: 600;
    position: relative;
    transition: color 0.3s ease;
}

.view-link:hover {
    color: #fff;
}

.view-link.active {
    color: #fff;
}

.view-link.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.4rem;
    height: 2px;
    background: linear-gradient(45deg, #00d4ff, #ff6b6b);
}

.view-separator {
    color: #555;
}

.username {
    color: #ccc;
    font-weight: 500;
}

.logout-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 6px;
    color: #ff6b6b;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(255, 107, 107, 0.3);
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

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

.camera-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.camera-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: rgba(0, 212, 255, 0.3);
}

.recordings-page {
    min-height: 100vh;
    background: #0a0a0a;
}

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

.recordings-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.recordings-card:hover {
    border-color: rgba(0, 212, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.recordings-card .card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-title {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}

.camera-ip-inline {
    color: #888;
    font-size: 0.85rem;
    font-weight: 500;
}

.recordings-list {
    display: flex;
    flex-direction: column;
    max-height: 500px;
    overflow-y: auto;
}

.recording-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    text-decoration: none;
    color: inherit;
    transition: background 0.3s ease, transform 0.2s ease;
}

.recording-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.recording-text {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.recording-title {
    font-weight: 600;
    color: #fff;
    font-size: 0.95rem;
}

.recording-subtitle {
    color: #aaa;
    font-size: 0.78rem;
    word-break: break-all;
}

.recordings-status {
    padding: 1.5rem;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    cursor: default;
}

.recordings-status.error {
    color: #ff6b6b;
    cursor: pointer;
}

.recordings-status.muted {
    color: #555;
}

.recording-sentinel {
    width: 100%;
    height: 1px;
}

.camera-preview {
    position: relative;
    aspect-ratio: 16/9;
    background: #141414;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: #777;
    gap: 0.75rem;
}

.camera-icon {
    font-size: 3.2rem;
}

.camera-info {
    padding: 1.5rem;
}

.camera-info h3 {
    margin-bottom: 0.35rem;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.camera-info h3 .camera-ip-inline {
    color: #888;
    font-size: 0.85rem;
    font-weight: 500;
}

.camera-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #888;
    font-size: 0.9rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Player Page */
.player-page {
    background: #000;
    overflow: hidden;
}

.player-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 10;
}

.player-header h2 {
    font-size: 1.2rem;
    color: #fff;
}

.player-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.close-btn {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.3);
}

.close-btn:hover {
    background: rgba(255, 107, 107, 0.3);
}

.video-container {
    flex: 1;
    position: relative;
    background: #000;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.connection-status {
    background: rgba(0, 0, 0, 0.8);
    padding: 1rem 2rem;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
}

.status-indicator.connecting {
    color: #00d4ff;
}

.status-indicator.connected {
    color: #4ade80;
}

.status-indicator.error {
    color: #ff6b6b;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.volume-control {
    position: absolute;
    top: 70px;
    right: 1rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 1rem;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    z-index: 20;
}

.volume-control input[type="range"] {
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
}

/* Fullscreen controls auto-hide */
.player-container.hide-controls .player-header {
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .cameras-grid {
        grid-template-columns: 1fr;
        gap: 1.2rem;
        padding: 0 0.5rem;
    }
    
    .camera-card {
        margin: 0 0.25rem;
    }
    
    .login-container {
        padding: 1rem;
    }
    
    .player-header {
        padding: 0.5rem;
    }
    
    .player-header h2 {
        font-size: 1rem;
    }
    
    .control-btn {
        width: 35px;
        height: 35px;
    }

    .recordings-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.5rem;
        padding: 0 0.5rem;
    }

    .card-title {
        flex-wrap: wrap;
    }
}

/* Loading states */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #666;
    font-size: 1.1rem;
}

.no-cameras {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #666;
    font-size: 1.1rem;
}
