/**
 * Frontend Styles for Xiaomi Firmware Manager
 * File: assets/css/frontend.css
 * Inspired by MiFirm.net design
 */

/* ==========================================================================
   Variables & Reset
   ========================================================================== */
:root {
    --xfm-primary: #ff6900;
    --xfm-secondary: #2c3e50;
    --xfm-success: #27ae60;
    --xfm-danger: #e74c3c;
    --xfm-light: #f8f9fa;
    --xfm-dark: #212529;
    --xfm-border: #dee2e6;
    --xfm-shadow: 0 2px 8px rgba(0,0,0,0.1);
    --xfm-radius: 8px;
}

/* ==========================================================================
   Search Bar & Filters
   ========================================================================== */
.xfm-search-bar {
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: var(--xfm-radius);
    box-shadow: var(--xfm-shadow);
}

.xfm-search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.xfm-search-input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid var(--xfm-border);
    border-radius: var(--xfm-radius);
    font-size: 16px;
    transition: border-color 0.3s;
}

.xfm-search-input:focus {
    outline: none;
    border-color: var(--xfm-primary);
}

.xfm-search-button {
    padding: 12px 30px;
    background: var(--xfm-primary);
    color: white;
    border: none;
    border-radius: var(--xfm-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.xfm-search-button:hover {
    background: #e55d00;
}

.xfm-filters {
    display: flex;
    gap: 10px;
}

.xfm-filters select {
    padding: 10px 15px;
    border: 2px solid var(--xfm-border);
    border-radius: var(--xfm-radius);
    font-size: 14px;
    cursor: pointer;
}

/* ==========================================================================
   Device Grid
   ========================================================================== */
.xfm-device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.xfm-device-card {
    background: white;
    border-radius: var(--xfm-radius);
    box-shadow: var(--xfm-shadow);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.xfm-device-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.xfm-device-image {
    width: 100%;
    height: 200px;
    background: var(--xfm-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.xfm-device-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.xfm-device-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    color: var(--xfm-border);
}

.xfm-device-info {
    padding: 20px;
}

.xfm-device-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--xfm-dark);
    margin: 0 0 8px 0;
}

.xfm-device-codename {
    font-size: 14px;
    color: #6c757d;
    margin: 0 0 15px 0;
    font-family: 'Courier New', monospace;
}

.xfm-device-stats {
    margin-bottom: 15px;
    padding: 10px;
    background: var(--xfm-light);
    border-radius: 5px;
    font-size: 13px;
    text-align: center;
}

.xfm-view-device-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--xfm-primary);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    transition: background 0.3s;
}

.xfm-view-device-btn:hover {
    background: #e55d00;
}

/* ==========================================================================
   Device Firmware Page
   ========================================================================== */
.xfm-firmware-container {
    max-width: 1200px;
    margin: 0 auto;
}

.xfm-device-header {
    display: flex;
    gap: 30px;
    padding: 30px;
    background: white;
    border-radius: var(--xfm-radius);
    box-shadow: var(--xfm-shadow);
    margin-bottom: 30px;
}

.xfm-device-header-image {
    width: 200px;
    height: 200px;
    flex-shrink: 0;
}

.xfm-device-header-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--xfm-radius);
}

.xfm-device-header-info h1 {
    margin: 0 0 15px 0;
    font-size: 32px;
    color: var(--xfm-dark);
}

.xfm-codename {
    font-family: 'Courier New', monospace;
    color: #6c757d;
    margin-bottom: 10px;
}

.xfm-specs {
    margin-bottom: 8px;
    color: #495057;
}

/* Region Tabs */
.xfm-region-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.xfm-tab-btn {
    padding: 12px 24px;
    background: white;
    border: 2px solid var(--xfm-border);
    border-radius: var(--xfm-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--xfm-secondary);
    transition: all 0.3s;
}

.xfm-tab-btn:hover {
    border-color: var(--xfm-primary);
    color: var(--xfm-primary);
}

.xfm-tab-btn.active {
    background: var(--xfm-primary);
    border-color: var(--xfm-primary);
    color: white;
}

/* Firmware Table */
.xfm-firmware-type-section {
    margin-bottom: 30px;
}

.xfm-firmware-type-title {
    padding: 15px 20px;
    background: var(--xfm-secondary);
    color: white;
    margin: 0 0 15px 0;
    border-radius: var(--xfm-radius);
}

.xfm-firmware-table-wrapper {
    background: white;
    border-radius: var(--xfm-radius);
    box-shadow: var(--xfm-shadow);
    overflow: hidden;
}

.xfm-firmware-table {
    width: 100%;
    border-collapse: collapse;
}

.xfm-firmware-table thead {
    background: var(--xfm-light);
}

.xfm-firmware-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--xfm-secondary);
    border-bottom: 2px solid var(--xfm-border);
}

.xfm-firmware-table td {
    padding: 15px;
    border-bottom: 1px solid var(--xfm-border);
}

.xfm-firmware-table tbody tr:hover {
    background: var(--xfm-light);
}

.xfm-version strong {
    color: var(--xfm-primary);
}

.xfm-download-btn {
    padding: 8px 20px;
    background: var(--xfm-success);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.xfm-download-btn:hover {
    background: #229954;
}

.xfm-download-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* ==========================================================================
   Download Modal
   ========================================================================== */
.xfm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.xfm-modal {
    background: white;
    border-radius: var(--xfm-radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { 
        transform: translateY(50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

.xfm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--xfm-border);
}

.xfm-modal-header h3 {
    margin: 0;
    color: var(--xfm-dark);
}

.xfm-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6c757d;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.xfm-modal-body {
    padding: 20px;
}

.xfm-filename {
    padding: 15px;
    background: var(--xfm-light);
    border-radius: 5px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.xfm-mirror-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.xfm-mirror-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: white;
    border: 2px solid var(--xfm-border);
    border-radius: var(--xfm-radius);
    text-decoration: none;
    color: var(--xfm-dark);
    transition: all 0.3s;
}

.xfm-mirror-btn:hover {
    border-color: var(--xfm-primary);
    background: #fff5f0;
}

.xfm-mirror-icon {
    font-size: 24px;
}

.xfm-mirror-label {
    flex: 1;
    font-weight: 600;
}

.xfm-mirror-speed {
    color: #6c757d;
    font-size: 14px;
}

.xfm-download-instructions {
    padding: 20px;
    background: #e8f4f8;
    border-radius: var(--xfm-radius);
    border-left: 4px solid #3498db;
}

.xfm-download-instructions h4 {
    margin: 0 0 10px 0;
    color: var(--xfm-secondary);
}

.xfm-download-instructions ol {
    margin: 0;
    padding-left: 20px;
}

.xfm-download-instructions li {
    margin-bottom: 5px;
    color: #495057;
}

/* ==========================================================================
   Statistics
   ========================================================================== */
.xfm-stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.xfm-stat-box {
    background: white;
    padding: 30px;
    border-radius: var(--xfm-radius);
    box-shadow: var(--xfm-shadow);
    text-align: center;
    transition: transform 0.3s;
}

.xfm-stat-box:hover {
    transform: translateY(-5px);
}

.xfm-stat-number {
    font-size: 36px;
    font-weight: 700;
    color: var(--xfm-primary);
    margin-bottom: 10px;
}

.xfm-stat-label {
    font-size: 14px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==========================================================================
   Notifications
   ========================================================================== */
.xfm-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background: white;
    border-radius: var(--xfm-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10001;
    transform: translateX(400px);
    transition: transform 0.3s;
}

.xfm-notification-show {
    transform: translateX(0);
}

.xfm-notification-success {
    border-left: 4px solid var(--xfm-success);
}

.xfm-notification-error {
    border-left: 4px solid var(--xfm-danger);
}

.xfm-notification-info {
    border-left: 4px solid #3498db;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
    .xfm-device-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .xfm-device-header {
        flex-direction: column;
    }
    
    .xfm-device-header-image {
        width: 100%;
    }
    
    .xfm-firmware-table-wrapper {
        overflow-x: auto;
    }
    
    .xfm-firmware-table {
        font-size: 14px;
    }
    
    .xfm-firmware-table th,
    .xfm-firmware-table td {
        padding: 10px;
    }
    
    .xfm-stats-container {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .xfm-device-grid {
        grid-template-columns: 1fr;
    }
    
    .xfm-stats-container {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Loading States
   ========================================================================== */
.xfm-loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.xfm-loading:before {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--xfm-border);
    border-top-color: var(--xfm-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.xfm-no-results {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    background: white;
    border-radius: var(--xfm-radius);
}