/* D3 IoT - LoRa Tool Web Application Styles */

/* Reset and 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%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
}

.header h1 {
    color: #39a57a;
    font-size: 1.8rem;
    font-weight: 600;
}

.header h1 i {
    margin-right: 10px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    color: #666;
    font-weight: 500;
}

.logout-btn {
    background: #e74c3c;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* Search Panel */
.search-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 100;
}

.search-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #39a57a;
    box-shadow: 0 0 0 3px rgba(57, 165, 122, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Radio Groups */
.radio-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.radio-label:hover {
    background: rgba(57, 165, 122, 0.1);
}

.radio-label input[type="radio"] {
    margin: 0;
    accent-color: #39a57a;
}

/* App Selector */
.app-selector-wrapper {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.app-selector {
    position: relative;
    z-index: 100;
    flex: 1;
}

.dropdown-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 200;
    max-height: 300px;
    overflow: hidden;
    margin-top: 5px;
}

/* Ensure dropdown appears above device selector */
.device-selector ~ .dropdown-menu,
.device-selector .dropdown-menu {
    z-index: 201;
}

.dropdown-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 5px 0;
}

.dropdown-item {
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:hover {
    background: rgba(57, 165, 122, 0.1);
}

.dropdown-item:last-child {
    border-bottom: none;
}

/* Device Selector */
.device-selector {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1;
    margin-top: 20px;
}

.device-selector-content {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    z-index: 1;
}

.device-dropdown {
    flex: 1;
    position: relative;
}

.device-dropdown select {
    width: 100%;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: #39a57a;
    color: white;
}

.btn-primary:hover {
    background: #2d8a5f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(57, 165, 122, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-refresh {
    background: #3498db;
    color: white;
    padding: 10px 12px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-refresh:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-refresh i.fa-spin {
    animation: fa-spin 1s infinite linear;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.search-section {
    display: flex;
    gap: 15px;
    align-items: center;
}

.date-section {
    display: flex;
    gap: 15px;
    align-items: center;
}

.date-section .form-group {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-section .form-group label {
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #666;
}

.date-section input[type="date"] {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9em;
    background: white;
    transition: border-color 0.3s ease;
}

.date-section input[type="date"]:focus {
    border-color: #39a57a;
    outline: none;
    box-shadow: 0 0 0 3px rgba(57, 165, 122, 0.1);
}

/* Results Panel */
.results-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 50;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e1e5e9;
}

.results-header h3 {
    color: #39a57a;
    font-size: 1.4rem;
}

.results-info {
    display: flex;
    gap: 20px;
    color: #666;
    font-size: 0.9rem;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    border-radius: 10px;
    border: 2px solid #e1e5e9;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.results-table th {
    background: #39a57a;
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.results-table td {
    padding: 12px;
    border-bottom: 1px solid #e1e5e9;
    font-size: 0.9rem;
}

.results-table tbody tr:hover {
    background: rgba(57, 165, 122, 0.05);
}

.results-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

/* Loading and No Results */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #666;
    font-size: 1.1rem;
}

.loading i {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #39a57a;
}

.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #666;
    font-size: 1.1rem;
}

.no-results i {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #f39c12;
}

/* Login Page Styles */
.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

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

.login-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header i {
    font-size: 3rem;
    color: #39a57a;
    margin-bottom: 15px;
}

.login-header h1 {
    color: #333;
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.login-header p {
    color: #666;
    font-size: 1rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .form-group {
    gap: 8px;
}

.login-form label {
    color: #555;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-form input {
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.login-form input:focus {
    outline: none;
    border-color: #39a57a;
    box-shadow: 0 0 0 3px rgba(57, 165, 122, 0.1);
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 15px;
    font-size: 1.1rem;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.login-footer p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.login-footer small {
    color: #999;
    font-size: 0.8rem;
}

/* Alert Styles */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.alert-success {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
    border: 1px solid rgba(39, 174, 96, 0.2);
}

.alert-error {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

.alert-info {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.2);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 15px;
    }
    
    .search-form {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 15px;
    }
    
    .search-section {
        justify-content: center;
    }
    
    .date-section {
        justify-content: center;
        flex-direction: column;
        gap: 10px;
    }
    
    .date-section .form-group {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-title {
        font-size: 1.5rem;
    }
    
    .search-form {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .app-selector-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-refresh {
        width: 100%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .radio-group {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 15px;
    }
    
    .search-section {
        justify-content: center;
        flex-direction: column;
        gap: 10px;
    }
    
    .date-section {
        justify-content: center;
        flex-direction: column;
        gap: 10px;
    }
    
    .date-section .form-group {
        width: 100%;
    }
    
    .results-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .device-selector-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    /* Make tables horizontally scrollable on mobile */
    .results-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .results-table {
        min-width: 600px;
        font-size: 0.8rem;
    }
    
    .results-table th,
    .results-table td {
        padding: 8px 4px;
    }
    
    /* Improve touch targets */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .radio-label {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .header-title {
        font-size: 1.2rem;
    }
    
    .search-panel,
    .device-selector,
    .results-panel {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input,
    .form-group select {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .radio-group {
        gap: 10px;
    }
    
    .radio-label {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .results-table {
        font-size: 0.7rem;
        min-width: 500px;
    }
    
    .results-table th,
    .results-table td {
        padding: 6px 2px;
        word-break: break-word;
    }
    
    .dropdown-menu {
        max-height: 200px;
    }
    
    .dropdown-item {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    .device-selector-content {
        gap: 8px;
    }
    
    .device-dropdown input,
    .device-dropdown select {
        font-size: 0.8rem;
        padding: 8px 10px;
    }
    
    .login-card {
        padding: 30px 20px;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .search-form {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .form-actions {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .date-section {
        flex-direction: row;
        gap: 10px;
    }
}
