/* Modern CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    text-align: center;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

h2 {
    font-size: 2rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 2rem 0 1rem 0;
    text-align: left;
}

h3 {
    font-size: 1.5rem;
    font-weight: 500;
    color: #34495e;
    margin: 1.5rem 0 1rem 0;
    text-align: left;
}

/* Links */
a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* Main Container */
.main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 2rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    margin-bottom: 2rem;
    color: white;
}

.hero-subtitle {
    font-size: 1.2rem;
    margin-top: 1rem;
    opacity: 0.9;
}

/* Statistics Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 1.5rem;
    border-radius: 15px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* Device Tables Section */
.tables-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 2rem 0;
}

.table-card {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    border: 1px solid #e1e8ed;
}

.table-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1rem;
    text-align: center;
}

/* Modern Table Styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
}

td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #e1e8ed;
    transition: background-color 0.3s ease;
}

tr:hover td {
    background-color: #f8f9fa;
}

tr:last-child td {
    border-bottom: none;
}

/* Quick Links Section */
.quick-links {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.link-card {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    color: white;
    display: block;
}

.link-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
    text-decoration: none;
    color: white;
}

.link-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.link-description {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Footer Styling */
footer {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    text-align: center;
    margin-top: auto;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 20px rgba(0,0,0,0.1);
}

footer img {
    vertical-align: middle;
    margin-left: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main {
        margin: 1rem;
        padding: 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .tables-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .links-grid {
        grid-template-columns: 1fr;
    }
    
    th, td {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }
    
    .table-title {
        font-size: 1.1rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
}

/* Form Elements */
input[type="radio"] {
    visibility: hidden;
}

input:checked+label {
    background: #27ae60;
    color: white;
}

label {
    display: block;
    padding: 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

label:hover {
    background: #3498db;
    color: white;
}

form {
    display: inline-block;
}

button[type="submit"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.3s ease;
}

button[type="submit"]:hover {
    transform: translateY(-2px);
}

/* Loading Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main {
    animation: fadeInUp 0.6s ease-out;
}

.stat-card {
    animation: fadeInUp 0.6s ease-out;
    animation-delay: 0.1s;
    animation-fill-mode: both;
}

.table-card {
    animation: fadeInUp 0.6s ease-out;
    animation-delay: 0.2s;
    animation-fill-mode: both;
}

/* Number Counter Animation */
@keyframes countUp {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.stat-number {
    animation: countUp 0.8s ease-out;
    animation-delay: 0.3s;
    animation-fill-mode: both;
}

/* Improved accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for better accessibility */
a:focus,
button:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    body {
        background: white !important;
    }
    
    .hero {
        background: #f8f9fa !important;
        color: #333 !important;
    }
    
    .stat-card,
    .link-card {
        background: #f8f9fa !important;
        color: #333 !important;
    }
}

/* Brand Page Specific Styles */
.table-container {
    overflow-x: auto;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.model-row {
    transition: all 0.3s ease;
    cursor: pointer;
}

.model-row:hover {
    background-color: #f8f9fa !important;
    transform: translateX(5px);
}

.model-name {
    font-weight: 600;
    color: #2c3e50;
}

.street-name {
    color: #666;
    font-style: italic;
}

.count-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.popularity-bar {
    width: 100px;
    height: 8px;
    background-color: #e1e8ed;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 0.2rem auto;
}

.popularity-fill {
    height: 100%;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    transition: width 0.3s ease;
}

.action-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.action-btn.primary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
    text-decoration: none;
    color: white;
}

/* Search and Sort Controls */
#modelSearch {
    transition: all 0.3s ease;
}

#modelSearch:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

#sortSelect {
    transition: all 0.3s ease;
}

#sortSelect:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Enhanced Table Styling for Brand Page */
.table-card table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.table-card th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    font-weight: 600;
    border: none;
}

.table-card td {
    padding: 1rem;
    border-bottom: 1px solid #e1e8ed;
    vertical-align: middle;
}

.table-card tr:last-child td {
    border-bottom: none;
}

/* Responsive Design for Brand Page */
@media (max-width: 768px) {
    .table-container {
        font-size: 0.9rem;
    }
    
    .table-card th,
    .table-card td {
        padding: 0.8rem 0.5rem;
    }
    
    .popularity-bar {
        width: 60px;
    }
    
    .action-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    #modelSearch {
        width: 250px;
    }
}

@media (max-width: 480px) {
    .table-card th:nth-child(4),
    .table-card td:nth-child(4) {
        display: none; /* Hide popularity column on very small screens */
    }
    
    .table-card th,
    .table-card td {
        padding: 0.6rem 0.3rem;
        font-size: 0.8rem;
    }
    
    #modelSearch {
        width: 200px;
    }
}

/* Loading Animation for Brand Page */
.loading-stats {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out forwards;
}

.loading-stats:nth-child(1) { animation-delay: 0.1s; }
.loading-stats:nth-child(2) { animation-delay: 0.2s; }
.loading-stats:nth-child(3) { animation-delay: 0.3s; }
.loading-stats:nth-child(4) { animation-delay: 0.4s; }

/* Enhanced Table Row Animations */
.model-row {
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInLeft 0.5s ease-out forwards;
}

.model-row:nth-child(1) { animation-delay: 0.1s; }
.model-row:nth-child(2) { animation-delay: 0.15s; }
.model-row:nth-child(3) { animation-delay: 0.2s; }
.model-row:nth-child(4) { animation-delay: 0.25s; }
.model-row:nth-child(5) { animation-delay: 0.3s; }

@keyframes slideInLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Search Results Animation */
.search-highlight {
    background-color: #fff3cd !important;
    transition: background-color 0.3s ease;
}

/* Brand Grade Styling */
.brand-grade {
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Model Page Specific Styles */
.device-row {
    transition: all 0.3s ease;
    cursor: pointer;
}

.device-row:hover {
    background-color: #f8f9fa !important;
    transform: translateX(3px);
}

.device-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.device-link {
    text-decoration: none;
    color: inherit;
}

.device-link:hover {
    text-decoration: none;
    color: inherit;
}

.count-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.restart-badge {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.awake-indicator {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: help;
}

.good-awake {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
}

.average-awake {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
}

.bad-awake {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.date-range {
    font-size: 0.85rem;
    line-height: 1.2;
}

.temp-info {
    font-size: 0.9rem;
    line-height: 1.3;
}

.level-indicator {
    font-size: 1rem;
    color: #27ae60;
    font-weight: 600;
}

/* Device thumbnail styling */
.device-thumbnail img {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.device-thumbnail:hover img {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* Enhanced table styling for model page */
.model-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.model-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0.5rem;
    font-weight: 600;
    border: none;
    font-size: 0.9rem;
}

.model-table td {
    padding: 1rem 0.5rem;
    border-bottom: 1px solid #e1e8ed;
    vertical-align: middle;
    font-size: 0.9rem;
}

.model-table tr:last-child td {
    border-bottom: none;
}

/* Performance indicators */
.performance-excellent {
    color: #27ae60;
    font-weight: 600;
}

.performance-good {
    color: #f39c12;
    font-weight: 600;
}

.performance-poor {
    color: #e74c3c;
    font-weight: 600;
}

/* Responsive design for model page */
@media (max-width: 1024px) {
    .model-table th:nth-child(3),
    .model-table td:nth-child(3) {
        display: none; /* Hide data period on tablets */
    }
}

@media (max-width: 768px) {
    .model-table th:nth-child(4),
    .model-table td:nth-child(4),
    .model-table th:nth-child(8),
    .model-table td:nth-child(8) {
        display: none; /* Hide restarts and temperature on mobile */
    }
    
    .model-table th,
    .model-table td {
        padding: 0.8rem 0.3rem;
        font-size: 0.8rem;
    }
    
    .device-preview img {
        max-width: 60px;
        max-height: 30px;
    }
}

@media (max-width: 480px) {
    .model-table th:nth-child(5),
    .model-table td:nth-child(5),
    .model-table th:nth-child(9),
    .model-table td:nth-child(9) {
        display: none; /* Hide avg uptime and battery level on very small screens */
    }
    
    .model-table th,
    .model-table td {
        padding: 0.6rem 0.2rem;
        font-size: 0.75rem;
    }
}

/* Loading animations for model page */
.device-row {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s ease-out forwards;
}

.device-row:nth-child(1) { animation-delay: 0.1s; }
.device-row:nth-child(2) { animation-delay: 0.15s; }
.device-row:nth-child(3) { animation-delay: 0.2s; }
.device-row:nth-child(4) { animation-delay: 0.25s; }
.device-row:nth-child(5) { animation-delay: 0.3s; }
.device-row:nth-child(6) { animation-delay: 0.35s; }
.device-row:nth-child(7) { animation-delay: 0.4s; }
.device-row:nth-child(8) { animation-delay: 0.45s; }

/* Search highlight effect */
.search-match {
    background-color: #fff3cd !important;
    transition: background-color 0.3s ease;
}

/* Tooltip styling */
[title] {
    position: relative;
}

/* Enhanced device thumbnail container */
.device-thumbnail {
    position: relative;
}

.device-thumbnail::after {
    content: '🔍 View Details';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 15px;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.device-thumbnail:hover::after {
    opacity: 1;
}

/* Filter buttons for model page */
.filter-btn {
    background: linear-gradient(135deg, #e1e8ed 0%, #d5dbdb 100%);
    color: #2c3e50;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.2rem;
}

.filter-btn:hover {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* Enhanced performance indicators */
.performance-excellent {
    color: #27ae60 !important;
    font-weight: 700;
}

.performance-good {
    color: #f39c12 !important;
    font-weight: 600;
}

.performance-poor {
    color: #e74c3c !important;
    font-weight: 600;
}

/* Enhanced device row animations */
.device-row {
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.device-row:hover {
    border-left-color: #3498db;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.device-row[data-performance="good"] {
    border-left-color: #27ae60;
}

.device-row[data-performance="high-usage"] {
    border-left-color: #f39c12;
}

/* Enhanced search match highlighting */
.search-match {
    background: linear-gradient(90deg, #fff3cd 0%, #ffffff 100%) !important;
    animation: highlightPulse 1s ease-out;
}

@keyframes highlightPulse {
    0% { background-color: #fff3cd; }
    50% { background-color: #ffeaa7; }
    100% { background-color: #fff3cd; }
}

/* Enhanced tooltip styling */
.awake-indicator[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 0.5rem;
    border-radius: 5px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

/* Enhanced device thumbnail effects */
.device-preview {
    position: relative;
    transition: all 0.3s ease;
}

.device-preview:hover {
    transform: scale(1.05);
}

.device-preview img {
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.device-preview:hover img {
    border-color: #3498db;
    box-shadow: 0 5px 20px rgba(52, 152, 219, 0.3);
}

/* Loading state for images */
.device-preview img[src*="placeholder"] {
    opacity: 0.6;
    filter: grayscale(100%);
}

/* Enhanced table responsiveness */
@media (max-width: 1200px) {
    .model-table th:nth-child(3),
    .model-table td:nth-child(3) {
        display: none; /* Hide data period on smaller screens */
    }
}

@media (max-width: 900px) {
    .model-table th:nth-child(4),
    .model-table td:nth-child(4),
    .model-table th:nth-child(8),
    .model-table td:nth-child(8) {
        display: none; /* Hide restarts and temperature */
    }
}

@media (max-width: 600px) {
    .model-table th:nth-child(5),
    .model-table td:nth-child(5) {
        display: none; /* Hide avg uptime */
    }
    
    .filter-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Enhanced statistics cards animation */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.stat-card:hover::before {
    left: 100%;
}

/* Enhanced awake ratio indicators */
.good-awake {
    position: relative;
}

.good-awake::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #27ae60;
    color: white;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bad-awake {
    position: relative;
}

.bad-awake::after {
    content: '!';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Sortable table styling */
.sortable-table th.sortable {
    transition: background-color 0.2s ease;
    user-select: none;
    position: relative;
}

.sortable-table th.sortable:hover {
    background-color: #f0f8ff !important;
}

.sort-indicator {
    font-size: 0.8rem;
    margin-left: 0.3rem;
    opacity: 0.7;
}

.sortable-table th.sortable:hover .sort-indicator {
    opacity: 1;
}

/* Enhanced device thumbnail styling */
.device-preview {
    transition: transform 0.2s ease;
}

.device-preview:hover {
    transform: scale(1.05);
}

.device-thumbnail img {
    transition: all 0.2s ease;
}

.device-thumbnail:hover img {
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* Table row animations */
.device-row {
    transition: all 0.2s ease;
}

.device-row:hover {
    background-color: #f8f9fa !important;
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Responsive table improvements */
@media (max-width: 1200px) {
    .model-table th:nth-child(2),
    .model-table td:nth-child(2),
    .model-table th:nth-child(4),
    .model-table td:nth-child(4) {
        display: none; /* Hide first/last snapshot on smaller screens */
    }
}

@media (max-width: 900px) {
    .model-table th:nth-child(9),
    .model-table td:nth-child(9),
    .model-table th:nth-child(10),
    .model-table td:nth-child(10) {
        display: none; /* Hide temperature columns */
    }
}

@media (max-width: 600px) {
    .model-table th:nth-child(5),
    .model-table td:nth-child(5) {
        display: none; /* Hide restarts column */
    }
    
    .sort-indicator {
        display: none; /* Hide sort indicators on very small screens */
    }
}
