/* Reset i podstawowe style */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.5;
}

/* Strona logowania */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.modal-content {
    padding: 40px;
}

.modal-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo-large {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
}

.logo-large i {
    font-size: 2rem;
    color: #667eea;
}

.logo-large h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.modal-header p {
    color: #666;
    font-size: 0.9rem;
}

/* Formularz logowania */
.login-form {
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
}

.input-wrapper {
    position: relative;
}

.input-group input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.login-btn:active {
    transform: translateY(0);
}

/* Komunikaty błędów */
.error-message {
    background: #fee;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message.hidden {
    display: none;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.login-footer p {
    color: #999;
    font-size: 0.8rem;
}

/* Główny interfejs */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.header {
    background: white;
    border-radius: 12px;
    padding: 20px 30px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo i {
    font-size: 2rem;
    color: #667eea;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-info span {
    font-weight: 500;
    color: #333;
}

.logout-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.logout-btn:hover {
    background: #c82333;
}

/* Panel sterowania */
.control-panel {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
}

.status-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    min-width: 0;
}

.status-item i {
    font-size: 1.5rem;
    color: #667eea;
    flex-shrink: 0;
}

.status-item .label {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 4px;
}

.status-item .value {
    font-weight: 600;
    color: #333;
    word-break: break-word;
}

.value.online {
    color: #28a745;
}

.value.offline {
    color: #dc3545;
}

/* Siatka kamer - NAPRAWIONA */
.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
    padding: 10px;
    width: 100%;
}

.camera-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 320px;
    position: relative;
}

.camera-card:hover {
    border-color: #667eea;
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.15);
}

.camera-preview {
    position: relative;
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    border: 2px solid #e1e5e9;
    overflow: hidden;
    flex-shrink: 0;
}

.camera-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    transition: transform 0.3s ease;
}

.fallback-icon {
    font-size: 3rem;
    color: #667eea;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.camera-image:not([src="placeholder.jpg"]) + .fallback-icon {
    display: none;
}

.camera-preview i {
    font-size: 2rem;
    color: #667eea;
}

.camera-card h3 {
    margin-bottom: 20px;
    color: #333;
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.6em;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.select-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    font-size: 1rem;
    margin-top: auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.select-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.select-btn:active {
    transform: translateY(0);
}

.select-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.camera-card.selected {
    border-color: #28a745;
    background: linear-gradient(135deg, #f8fff9 0%, #e8f5e8 100%);
}

.camera-card.selected .select-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.camera-grid.control-disabled .camera-card {
    opacity: 0.7;
    cursor: not-allowed;
}

.camera-grid.control-disabled .select-btn {
    background: #6c757d;
    cursor: not-allowed;
}

/* Loading state dla zdjęć */
.camera-image.loading {
    opacity: 0.7;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Panel informacji o kontroli */
.control-info {
    margin-top: 30px;
    width: 100%;
}

.queue-info, .control-info-panel {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.control-info-panel {
    background: #d1ecf1;
    border-color: #bee5eb;
}

.queue-info h4, .control-info-panel h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #856404;
    flex-wrap: wrap;
}

.control-info-panel h4 {
    color: #0c5460;
}

.timer {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.timer-progress {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    min-width: 100px;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    transition: width 1s linear;
}

.timer-text {
    font-weight: 600;
    color: #333;
    min-width: 50px;
    white-space: nowrap;
}

.control-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.control-btn.secondary {
    background: #dc3545;
}

.control-btn:hover {
    opacity: 0.9;
}

/* Powiadomienia */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 400px;
    word-break: break-word;
}

.notification-success {
    background: #28a745;
}

.notification-error {
    background: #dc3545;
}

.notification-warning {
    background: #ffc107;
    color: #333;
}

.notification-info {
    background: #17a2b8;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Klasy pomocnicze */
.hidden {
    display: none !important;
}

/* STYLE DODANE Z INDEX.PHP */
.user-status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 10px;
    white-space: nowrap;
}
.status-active {
    background: #d4edda;
    color: #155724;
}
.status-waiting {
    background: #fff3cd;
    color: #856404;
}
.status-inactive {
    background: #f8d7da;
    color: #721c24;
}
.control-timer {
    background: #004085;
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    margin: 15px 0;
    font-size: 18px;
    font-weight: bold;
    width: 100%;
}
.queue-timer {
    background: #856404;
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    margin: 15px 0;
    font-size: 18px;
    font-weight: bold;
    width: 100%;
}
.timer-warning {
    background: #856404;
}
.timer-critical {
    background: #721c24;
    animation: blink 1s infinite;
}
@keyframes blink {
    50% { opacity: 0.7; }
}
.timer-progress {
    width: 100%;
    height: 10px;
    background: rgba(255,255,255,0.3);
    border-radius: 5px;
    margin: 10px 0;
    overflow: hidden;
}
.timer-fill {
    height: 100%;
    background: #4CAF50;
    transition: width 1s linear;
}
.queue-timer-fill {
    height: 100%;
    background: #ffc107;
    transition: width 1s linear;
}
.control-disabled {
    opacity: 0.5;
    pointer-events: none;
}
.active-controller-info {
    background: #e8f5e8;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
    width: 100%;
}
.debug-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 10px;
    margin: 10px 0;
    font-size: 12px;
    color: #6c757d;
    width: 100%;
}
.queue-time-info {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}
.estimated-time {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    padding: 8px;
    margin: 10px 0;
    width: 100%;
}
.time-badge {
    background: #17a2b8;
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

/* Kolejka użytkowników */
.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #6c757d;
    flex-wrap: wrap;
}

.queue-item.active {
    background: #d4edda;
    border-left-color: #28a745;
}

.queue-item.current-user {
    background: #e7f3ff;
    border-left-color: #007bff;
}

.queue-position {
    font-weight: bold;
    min-width: 20px;
}

.queue-username {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.queue-status {
    font-size: 0.8rem;
    white-space: nowrap;
}

/* RESPONSYWNOŚĆ - NAPRAWIONA */
@media (max-width: 1200px) {
    .camera-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .container {
        padding: 15px;
    }
    
    .control-panel {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 15px;
    }
    
    .user-info {
        justify-content: center;
        width: 100%;
    }
    
    .camera-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 15px;
        padding: 5px;
    }
    
    .camera-card {
        padding: 15px;
        min-height: 280px;
    }
    
    .camera-preview {
        height: 150px;
        margin-bottom: 15px;
    }
    
    .fallback-icon {
        font-size: 2.5rem;
    }
    
    .camera-card h3 {
        font-size: 1rem;
        margin-bottom: 15px;
        min-height: 2.4em;
    }
    
    .select-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .status-panel {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .status-item {
        padding: 15px;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    .control-timer,
    .queue-timer {
        font-size: 16px !important;
        padding: 12px !important;
        margin: 10px 0 !important;
    }
    
    .timer-progress {
        height: 8px !important;
    }
    
    .timer-text {
        font-size: 18px !important;
        font-weight: bold;
    }
    
    .queue-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .queue-username {
        flex: none;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .camera-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .camera-card {
        padding: 12px;
        min-height: 260px;
    }
    
    .camera-preview {
        height: 140px;
    }
    
    .fallback-icon {
        font-size: 2rem;
    }
    
    .container {
        padding: 10px;
    }
    
    .control-panel {
        padding: 15px;
    }
    
    .logo h1 {
        font-size: 1.3rem;
    }
    
    .user-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .user-status-badge {
        margin-left: 0;
    }
}

/* Zapobiegaj zoomowaniu przy kliknięciu */
select, input, button, .select-btn {
    font-size: 16px;
}

/* Lepsze renderowanie na mobile */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* Lepsze targety dotykowe */
button, .select-btn, .control-btn {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Zapobiegaj przepełnieniu tekstu */
.control-info-panel,
.queue-info,
.active-controller-info {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .camera-card {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .camera-card h3 {
        color: #e2e8f0;
    }
    
    .camera-preview {
        background: #4a5568;
        border-color: #718096;
    }
}