/* ========================================
   DEVICE CONTROL PAGE STYLES
   Dedicated stylesheet for DeviceControl.razor
   Dark Industrial Theme
   ======================================== */

/* ========== SCROLLING SUPPORT ========== */
/* Override PageTransitionWrapper's height: 100% to allow scrolling */
.page-transition-wrapper:has(.device-control-container),
.page-content:has(.device-control-container) {
    height: auto !important;
    min-height: 100%;
}

/* Ensure the app-content can scroll when device-control-container is present */
.app-content:has(.device-control-container) {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* ========== CONTAINER ========== */
.device-control-container {
    padding: 1rem;
    padding-bottom: 5rem; /* Extra space for FAB and bottom content */
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== HEADER CARD ========== */
.device-control-container .header-card {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(0, 188, 212, 0.1);
}

.device-control-container .header-content {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    position: relative;
}

.device-control-container .header-text {
    text-align: center;
    flex: 1;
}

.device-control-container .header-text h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 400;
    color: #00bcd4;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.device-control-container .header-text h1 i {
    color: #00bcd4;
}

.device-control-container .header-text p {
    margin: 0.25rem 0 0 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

/* ========== BACK BUTTON ========== */
.device-control-container .btn-back {
    position: absolute;
    left: 0;
    background: transparent;
    border: 1px solid rgba(0, 188, 212, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.device-control-container .btn-back:hover:not(:disabled) {
    background: rgba(0, 188, 212, 0.1);
    border-color: #00bcd4;
    color: #00bcd4;
}

.device-control-container .btn-back:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ========== CONNECTION STATUS CARD ========== */
.connected-device-card {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(0, 188, 212, 0.1);
    overflow: hidden;
}

.connected-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid rgba(0, 188, 212, 0.1);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.1);
}

.status-indicator.connected {
    background: #4caf50;
    animation: pulse-green 2s infinite;
}

.status-indicator.connecting {
    background: #ff9800;
    animation: pulse-orange 1.5s infinite;
}

.status-indicator.disconnected {
    background: #f44336;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0.1); }
    100% { box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3); }
}

@keyframes pulse-orange {
    0% { box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(255, 152, 0, 0.1); }
    100% { box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3); }
}

.connection-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
}

.connection-info p {
    margin: 0.25rem 0 0 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

/* ========== DISCONNECT BUTTON ========== */
.disconnect-btn {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.disconnect-btn:hover:not(:disabled) {
    background: rgba(244, 67, 54, 0.2);
    border-color: #f44336;
}

/* ========== DISCONNECT OPTIONS ========== */
.disconnect-options {
    display: flex;
    gap: 0.75rem;
}

.disconnect-options .e-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.disconnect-options .e-btn.e-primary {
    background: rgba(0, 188, 212, 0.1);
    color: #00bcd4;
    border: 1px solid rgba(0, 188, 212, 0.3);
}

.disconnect-options .e-btn.e-primary:hover {
    background: rgba(0, 188, 212, 0.2);
    border-color: #00bcd4;
}

/* ========== CONNECTION ERROR ========== */
.connection-error {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 152, 0, 0.1);
    border-top: 1px solid rgba(255, 152, 0, 0.2);
    color: #ff9800;
}

.connection-error i {
    font-size: 1.25rem;
    color: #ff9800;
}

/* ========== DEVICE STATUS CARD ========== */
.device-status-card {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(0, 188, 212, 0.1);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 188, 212, 0.1);
}

.section-header i {
    font-size: 1.25rem;
    color: #00bcd4;
}

.section-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 400;
    color: #00bcd4;
}

/* ========== STATUS GRID ========== */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1.25rem;
}

.status-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: rgba(0, 188, 212, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(0, 188, 212, 0.15);
    transition: all 0.3s ease;
}

.status-item:hover {
    background: rgba(0, 188, 212, 0.08);
    border-color: rgba(0, 188, 212, 0.3);
}

.status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(0, 188, 212, 0.1);
    border-radius: 50%;
    margin-bottom: 0.75rem;
}

.status-icon i {
    font-size: 1.1rem;
    color: #00bcd4;
}

.status-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.status-details label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-details span {
    font-size: 1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
}

.status-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-item label i {
    color: #00bcd4;
    font-size: 0.9rem;
}

.status-item .value {
    font-size: 1.25rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.9);
}

.status-item .value.connected {
    color: #4caf50;
}

.status-item .value.error {
    color: #f44336;
}

/* Status text colors */
.status-connected {
    color: #4caf50;
}

.status-disconnected {
    color: #f44336;
}

/* ========== CONNECTION FAILED STATUS ========== */
.connection-failed-status {
    text-align: center;
    padding: 3rem 2rem;
}

.connection-failed-status i {
    color: #f44336;
    margin-bottom: 1.5rem;
    display: block;
}

.connection-failed-status h4 {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.connection-failed-status p {
    margin: 0 0 1.5rem 0;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1rem;
}

.connection-failed-status .e-btn {
    background: rgba(0, 188, 212, 0.1);
    border: 1px solid rgba(0, 188, 212, 0.3);
    padding: 0.75rem 2rem;
    border-radius: 6px;
    color: #00bcd4;
    font-weight: 400;
}

/* ========== COMMANDS CARD ========== */
.commands-card {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(0, 188, 212, 0.1);
}

.commands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1.25rem;
}

.command-btn {
    padding: 1rem;
    background: rgba(0, 188, 212, 0.08);
    color: #00bcd4;
    border: 1px solid rgba(0, 188, 212, 0.2);
    border-radius: 6px;
    font-weight: 400;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.command-btn:hover:not(:disabled) {
    background: rgba(0, 188, 212, 0.15);
    border-color: #00bcd4;
}

.command-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(128, 128, 128, 0.05);
    border-color: rgba(128, 128, 128, 0.2);
    color: rgba(255, 255, 255, 0.3);
}

.command-btn i {
    font-size: 1.5rem;
}

.command-btn span {
    font-size: 0.9rem;
}

.commands-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ========== SKELETON LOADER ========== */
.skeleton-loader {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    height: 20px;
    margin-bottom: 0.5rem;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========== ORGANIZATION BINDING CARD ========== */
.organization-binding-card {
    margin-top: 1rem;
}

.org-binding-content {
    padding: 1rem;
}

/* ========== ORGANIZATION INFO SECTION ========== */
.org-info-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 188, 212, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(0, 188, 212, 0.1);
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.info-row:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
    min-width: 120px;
}

.info-row label i {
    color: #00bcd4;
    font-size: 0.9rem;
}

.info-row span {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
}

/* ========== CONTACT SECTIONS ========== */
.contact-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.contact-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 400;
    color: #00bcd4;
}

.contact-header i {
    font-size: 1.1rem;
}

.contact-info {
    padding-left: 0.5rem;
}

/* ========== NOT LINKED STATUS ========== */
.not-linked-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.not-linked-status i {
    color: rgba(0, 188, 212, 0.5);
    font-size: 1.5rem;
}

/* ========== CURRENT ORGANIZATION STATUS ========== */
.current-org-status {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.current-org-status label {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.org-name {
    font-size: 1.1rem;
    color: #00bcd4;
    font-weight: 500;
}

.no-org {
    font-style: italic;
    color: rgba(255, 255, 255, 0.4);
}

/* ========== BINDING ACTIONS ========== */
.binding-actions {
    margin-bottom: 1rem;
}

.bind-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.bind-controls .e-ddl {
    min-width: 250px;
    flex: 1;
}

.unbind-btn, .bind-btn {
    min-width: 200px;
}

/* ========== WARNING AND MESSAGE STATES ========== */
.permission-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: rgba(255, 152, 0, 0.1);
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: 4px;
    color: #ff9800;
    margin-top: 1rem;
}

.permission-warning i {
    color: #ff9800;
}

.binding-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.binding-message.success {
    background-color: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: #4caf50;
}

.binding-message.error {
    background-color: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: #f44336;
}

/* ========== LOADING AND ERROR STATUS ========== */
.loading-status, .error-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.6);
}

.error-status {
    color: #f44336;
}

.no-orgs-message {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    margin: 0;
}

/* ========== NO CONTACT INFO ========== */
.no-contact-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.no-contact-info i {
    color: rgba(0, 188, 212, 0.5);
    font-size: 1.2rem;
}

/* ========== FLOATING ACTION BUTTON ========== */
#refreshFab {
    position: fixed;
    bottom: max(2rem, env(safe-area-inset-bottom));
    right: max(2rem, env(safe-area-inset-right));
    z-index: 1200;
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 768px) {
    .device-control-container {
        padding: 0.5rem;
    }
    .device-control-container .btn-back {
        display: none;
    }
    .device-control-container .header-text h1 {
        font-size: 1.25rem;
    }

    .status-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.75rem;
        padding: 1rem;
    }

    .commands-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 0.75rem;
        padding: 1rem;
    }

    .connected-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .disconnect-options {
        flex-direction: column;
    }

    .info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .info-row label {
        min-width: auto;
    }

    .bind-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .bind-controls .e-ddl {
        min-width: 100%;
    }

    #refreshFab {
        bottom: max(0.75rem, env(safe-area-inset-bottom));
        right: max(0.75rem, env(safe-area-inset-right));
    }
}

