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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.5;
    font-size: 14px;
}

/* Header */
.main-header {
    background-color: #002673; /* Deep blue from image */
    color: white;
    height: 80px; /* Increased from 60px */
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: none; /* Removed shadow to match clean look */
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: 500;
}

.logo-icon-wrapper {
    width: 32px;
    height: 32px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-svg {
    width: 100%;
    height: 100%;
}

.logo-svg circle {
    fill: #2979ff; /* Brighter blue for logo circle */
}

.logo-svg path {
    fill: white;
    stroke: none;
}

.logo-text {
    font-weight: bold;
    font-size: 22px; /* Increased size */
    letter-spacing: 1px;
}

.divider {
    margin: 0 15px;
    opacity: 0.5;
    font-weight: 300;
    font-size: 20px;
}

.sub-text {
    font-size: 14px;
    opacity: 0.9;
    padding-top: 4px; /* Align with bottom of main text slightly */
}

/* Main Container */
.main-container {
    max-width: 1200px;
    margin: 30px auto; /* Increased top margin */
    padding: 0 20px;
}

/* Top Info Card */
.info-card {
    background: white;
    border-radius: 4px;
    padding: 40px; /* Increased padding */
    position: relative;
    margin-bottom: 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    min-height: 300px;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.company-section {
    flex: 1;
}

.company-section h1 {
    font-size: 28px; /* Increased font size */
    color: #333;
    margin-bottom: 15px;
    font-weight: normal;
}

.meta-info {
    font-size: 14px;
    color: #666;
    display: flex;
    gap: 40px; /* Increased gap */
}

.meta-info span {
    margin-right: 0;
}

.qr-code {
    position: static; /* Removed absolute positioning */
}

.qr-code img {
    width: 80px;
    height: 80px;
}

.stats-center {
    text-align: center;
    margin-top: 60px; /* Increased top margin for more spacing */
    padding-top: 0;
    position: relative;
    padding-bottom: 30px; /* Adjusted spacing to 30px */
}

.stats-center::after {
    content: '';
    display: block;
    width: 890px; /* Explicitly set to 1280px as requested */
    height: 1px;
    background-color: #eee;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.stats-center h2 {
    font-size: 32px; /* Increased font size */
    color: #333;
    font-weight: bold;
    margin-bottom: 30px; /* Increased spacing */
    letter-spacing: 1px;
}

.stat-number {
    font-size: 60px; /* Reduced to 60px */
    font-weight: bold;
    color: #333;
    line-height: 1;
    margin-bottom: 15px;
    display: flex;
    align-items: baseline; /* Align baseline for better text alignment */
    justify-content: center;
    gap: 2px;
    font-family: Arial, sans-serif;
}

.stat-number .unit {
    font-size: 16px; /* Smaller unit size */
    color: #000000;
    font-weight: normal;
}

.stat-label {
    font-size: 16px; /* Slightly larger label */
    color: #666;
    margin-top: 10px;
    letter-spacing: 1px;
}

/* Ranking Results Section */
.results-section {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
    /* Removed card styles */
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 0;
    border-bottom: none; /* Removed border */
}

.section-header h3 {
    font-size: 28px; /* Larger title */
    color: #333;
    font-weight: bold;
    margin: 0;
}

.controls {
    display: flex;
    gap: 10px;
}

.search-input, .sort-select {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    background: #fff; /* Ensure white background */
}

.search-input {
    width: 250px;
}

.search-btn {
    padding: 10px 20px;
    background: #1890ff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.search-btn:hover {
    background: #40a9ff;
}

/* Table Grid Layout */
.tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.table-wrapper {
    /* Add card styles here */
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed; /* Fixed layout for better column width control */
}

.ranking-table th {
    text-align: left;
    padding: 10px;
    font-weight: bold;
    color: #333;
    border-bottom: 1px solid #eee;
    background-color: #fafafa;
}

.ranking-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Column Widths */
.col-index { width: 50px; }
.col-keyword { width: auto; }
.ranking-table th.col-rank { width: 120px; text-align: center; } /* Increased specificity and width */

.ranking-table td.cell-rank {
    text-align: center;
    overflow: visible;
}

.keyword-link {
    color: #1890ff;
    text-decoration: none;
}

.keyword-link:hover {
    text-decoration: underline;
}

.rank-tag {
    color: #1890ff;
    background: #e6f7ff;
    border: 1px solid #91d5ff;
    padding: 1px 6px; /* Reduced padding for compact look */
    border-radius: 3px; /* Slightly smaller radius */
    font-size: 12px; /* Smaller font */
    display: inline-block;
    min-width: auto; /* Removed fixed width */
    text-align: center;
    white-space: nowrap;
    margin-right: 0; /* Ensure alignment with header */
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px; /* Increased gap slightly */
    margin-top: 40px;
    margin-bottom: 40px; /* Space before footer */
    font-size: 14px;
    color: #666;
}

.page-btn {
    border: 1px solid #d9d9d9;
    background: white;
    width: 32px; /* Fixed width */
    height: 32px; /* Fixed height */
    padding: 0;
    line-height: 30px; /* Vertically center text */
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    color: #666;
    transition: all 0.2s;
    font-family: Arial, sans-serif;
}

.page-btn:hover {
    border-color: #1890ff;
    color: #1890ff;
}

.page-btn.active {
    background-color: #1890ff;
    color: white;
    border-color: #1890ff;
}

.page-btn:disabled {
    cursor: not-allowed;
    background-color: #f5f5f5;
    color: #ccc;
    border-color: #d9d9d9;
}

.goto-input {
    width: 50px;
    height: 32px;
    padding: 0 5px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    text-align: center;
    margin: 0 5px;
    outline: none;
    transition: all 0.2s;
}

.goto-input:focus {
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.total-count {
    margin-right: 10px;
}

.goto-text {
    margin-left: 10px;
}

/* Footer */
.main-footer {
    background-color: #eeeeee; /* Changed to #777777 */
    text-align: center;
    padding: 15px 0; /* Reduced padding for lower height */
    color: #777777; /* Changed to white for better contrast */
    font-size: 12px;
    width: 100%;
    margin-top: 0;
    border-top: none; /* Removed border as it might not be needed on darker background */
}

.main-footer p {
    margin: 0;
}

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

.admin-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.admin-content h3 {
    margin-bottom: 20px;
    font-size: 18px;
    color: #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.admin-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
}

#data-input {
    width: 100%;
    height: 200px;
    padding: 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 20px;
}

.admin-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.admin-btn {
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    font-size: 14px;
}

.admin-btn.save {
    background: #1890ff;
    color: white;
    padding: 10px 24px;
    font-weight: 500;
}

.admin-btn.save:hover {
    background: #40a9ff;
}

.admin-btn.cancel {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #d9d9d9;
}

.admin-btn.cancel:hover {
    background: #e8e8e8;
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    /* Header */
    .main-header {
        height: auto;
        padding: 15px 20px;
    }

    .header-content {
        flex-direction: column;
        align-items: center;
    }

    .logo {
        margin-bottom: 0;
    }

    /* Main Container */
    .main-container {
        margin: 20px auto;
        padding: 0 10px;
    }

    /* Info Card */
    .info-card {
        padding: 20px;
        min-height: auto;
    }

    .info-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-bottom: 30px;
    }

    .company-section {
        margin-bottom: 20px;
    }

    .company-section h1 {
        font-size: 24px;
    }

    .meta-info {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }

    .qr-code {
        margin-top: 10px;
    }
    
    .qr-code img {
        width: 100px;
        height: 100px;
    }

    .stats-center {
        margin-top: 30px;
        padding-bottom: 20px;
    }

    .stats-center::after {
        width: 100%;
    }

    .stats-center h2 {
        font-size: 24px;
    }

    .stat-number {
        font-size: 48px;
    }

    /* Results Section */
    .results-section {
        margin: 20px auto;
        padding: 0 10px;
    }

    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .section-header h3 {
        text-align: center;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .search-input {
        width: 100%;
    }

    .sort-select {
        width: 100%;
    }

    .search-btn {
        width: 100%;
        justify-content: center;
    }

    /* Tables */
    .tables-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .table-wrapper {
        padding: 10px;
        overflow-x: auto;
    }

    .ranking-table th, 
    .ranking-table td {
        padding: 8px 5px;
    }
    
    .col-index { width: 35px; }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }

    .total-count {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
    }

    /* Admin Modal */
    .admin-content {
        padding: 20px;
        max-height: 80vh;
    }
}
