/**
 * TTLock Frontend Interface CSS
 * Comprehensive styling for the frontend interface similar to ISL Key software
 */

/* Base Interface Styles */
.ttlock-interface {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    min-height: 600px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Navigation Styles */
.ttlock-nav {
    background: #2c3e50;
    padding: 0;
    margin: 0;
}

.nav-tabs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    border-bottom: none;
}

.nav-tabs li {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 15px 25px;
    color: #bdc3c7;
    text-decoration: none;
    border: none;
    background: none;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-link:hover {
    color: #ecf0f1;
    background: rgba(255,255,255,0.1);
}

.nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-bottom-color: #3498db;
}

/* Content Area */
.ttlock-content {
    position: relative;
    padding: 20px;
    background: #fff;
}

.view-content {
    display: none;
}

.view-content.active {
    display: block;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dashboard Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.dashboard-card h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-item {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: #3498db;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Button Styles */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #e67e22;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Interface Header */
.interface-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.interface-header h2 {
    margin: 0;
    color: #2c3e50;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Filters Bar */
.filters-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.filters-bar input,
.filters-bar select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.filters-bar input:focus,
.filters-bar select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Bulk Actions */
.bulk-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

/* Locks Grid */
.locks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.lock-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
}

.lock-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.lock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.lock-header h4 {
    margin: 0;
    color: #2c3e50;
}

.lock-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.lock-status.locked {
    background: #e74c3c;
    color: white;
}

.lock-status.unlocked {
    background: #27ae60;
    color: white;
}

.lock-details {
    margin-bottom: 15px;
}

.lock-details p {
    margin: 5px 0;
    font-size: 14px;
    color: #6c757d;
}

.lock-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* eKeys Table */
.ekeys-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

.ttlock-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ttlock-table th,
.ttlock-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.ttlock-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    text-transform: uppercase;
    font-size: 12px;
}

.ttlock-table tbody tr:hover {
    background: #f8f9fa;
}

.status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.status.active {
    background: #d4edda;
    color: #155724;
}

.status.frozen {
    background: #f8d7da;
    color: #721c24;
}

/* Groups Grid */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.group-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
}

.group-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.group-header h4 {
    margin: 0;
    color: #2c3e50;
}

.group-lock-count {
    background: #3498db;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.group-description {
    margin-bottom: 15px;
    color: #6c757d;
    font-size: 14px;
}

.group-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

/* Modals */
.ttlock-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e9ecef;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    margin-bottom: 0;
}

.checkbox-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 10px;
}

.checkbox-item {
    display: block;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.checkbox-item:hover {
    background: #f8f9fa;
}

.checkbox-item input {
    margin-right: 8px;
    width: auto;
}

/* No Data Message */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ttlock-interface {
        margin: 0;
        border-radius: 0;
    }
    
    .nav-tabs {
        flex-wrap: wrap;
    }
    
    .nav-link {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .dashboard-grid,
    .locks-grid,
    .groups-grid {
        grid-template-columns: 1fr;
    }
    
    .interface-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters-bar input,
    .filters-bar select {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .ekeys-table-container {
        font-size: 12px;
    }
    
    .ttlock-table th,
    .ttlock-table td {
        padding: 8px 10px;
    }
}

/* Theme Variations */
.ttlock-interface.theme-dark {
    background: #2c3e50;
    color: #ecf0f1;
}

.ttlock-interface.theme-dark .ttlock-content {
    background: #34495e;
}

.ttlock-interface.theme-dark .dashboard-card,
.ttlock-interface.theme-dark .lock-card,
.ttlock-interface.theme-dark .group-card {
    background: #3c4f66;
    border-color: #4a5f7a;
    color: #ecf0f1;
}

.ttlock-interface.theme-dark .ttlock-table {
    background: #3c4f66;
    color: #ecf0f1;
}

.ttlock-interface.theme-dark .ttlock-table th {
    background: #2c3e50;
}

/* Print Styles */
@media print {
    .ttlock-nav,
    .header-actions,
    .filters-bar,
    .bulk-actions,
    .pagination-controls,
    .lock-actions,
    .group-actions,
    .btn {
        display: none !important;
    }
    
    .ttlock-interface {
        box-shadow: none;
        border: 1px solid #000;
    }
}
