/**
 * EW Xchange API - Frontend Styles
 *
 * @package EW_Xchange_API
 */

/* ========================================
   Stock Table Styles
   ======================================== */

.ewx-stock-wrapper {
    margin-bottom: 20px;
}

.ewx-stock-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.ewx-stock-header strong {
    font-size: 18px;
    color: #333;
}

.ewx-company-name {
    margin-left: 8px;
    color: #666;
    font-size: 14px;
}

.ewx-stock-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
}

.ewx-stock-table th,
.ewx-stock-table td {
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 12px 10px;
    text-align: center;
}

.ewx-stock-table th:last-child,
.ewx-stock-table td:last-child {
    border-right: none;
}

.ewx-stock-table tr:last-child td {
    border-bottom: none;
}

.ewx-stock-table th {
    background: #f4f4f4;
    font-weight: 600;
    color: #333;
}

.ewx-stock-table tbody tr:hover {
    background-color: #f9f9f9;
}

.ewx-val-up {
    color: #22c55e;
    font-weight: 600;
}

.ewx-val-down {
    color: #ef4444;
    font-weight: 600;
}

.ewx-updated {
    display: block;
    color: #666;
    font-size: 12px;
    margin-top: 8px;
}

.ewx-no-data {
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #666;
    text-align: center;
}

/* ========================================
   Custom Value Table (Multi-select)
   ======================================== */

.ewx-custom-table {
    width: 100%;
    max-width: 400px;
    border-collapse: collapse;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.ewx-custom-table th,
.ewx-custom-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.ewx-custom-table tr:last-child th,
.ewx-custom-table tr:last-child td {
    border-bottom: none;
}

.ewx-custom-table th {
    background: #f8fafc;
    font-weight: 500;
    color: #64748b;
    text-align: left;
    width: 45%;
}

.ewx-custom-table td {
    background: #fff;
    font-weight: 600;
    color: #1e293b;
    text-align: right;
}

.ewx-custom-table tr:hover th,
.ewx-custom-table tr:hover td {
    background: #f1f5f9;
}

/* ========================================
   News Table Styles
   ======================================== */

.ewx-news-wrapper {
    margin: 20px 0;
}

.ewx-news-table {
    width: 100%;
    border-collapse: collapse;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
}

.ewx-news-table th,
.ewx-news-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

.ewx-news-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #ddd;
}

.ewx-news-table tbody tr:hover {
    background-color: #f9f9f9;
}

.ewx-news-table .ewx-date {
    white-space: nowrap;
    color: #666;
}

.ewx-news-link {
    color: #0073aa;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.ewx-news-link:hover {
    color: #005177;
}

/* ========================================
   Modal Styles
   ======================================== */

.ewx-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    animation: ewx-fade-in 0.2s ease-out;
}

@keyframes ewx-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ewx-modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border: none;
    width: 90%;
    max-width: 800px;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: ewx-slide-in 0.3s ease-out;
}

@keyframes ewx-slide-in {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.ewx-modal-content h2 {
    margin: 0;
    padding: 20px 50px 20px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 18px;
    border-radius: 8px 8px 0 0;
}

.ewx-close {
    position: absolute;
    top: 12px;
    right: 16px;
    color: #999;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.ewx-close:hover,
.ewx-close:focus {
    color: #333;
    outline: none;
}

.ewx-modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Modal Table Styles - SGX Announcement Content */
.ewx-modal-body table {
    width: 100%;
    border-collapse: collapse;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.ewx-modal-body table tr {
    border-bottom: 1px solid #e5e7eb;
}

.ewx-modal-body table td {
    padding: 12px 14px;
    vertical-align: top;
    word-break: break-word;
}

/* Label column (first cell in two-cell rows) */
.ewx-modal-body table td:first-child {
    width: 35%;
    font-weight: 600;
    color: #1f2937;
    background: #f9fafb;
}

/* Value column */
.ewx-modal-body table td+td {
    color: #374151;
    background: #fff;
}

/* Section header rows (single cell with colspan) */
.ewx-modal-body table tr td:only-child {
    font-weight: 700;
    background: #dae8f2;
    color: #0369a1;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid #7dd3fc;
    font-size: 12px;
}

/* Top announcement title (first row, single cell) */
.ewx-modal-body table tr:first-child td:only-child {
    font-size: 14px;
    background: #dae8f2;
    color: #0369a1;
    border-bottom: 2px solid #7dd3fc;
    text-transform: none;
    letter-spacing: normal;
    display: none;
}

/* Zebra effect for data rows */
.ewx-modal-body table tr:nth-child(even) td:not(:only-child) {
    background: #fcfcfd;
}

.ewx-modal-body table tr:nth-child(even) td:first-child:not(:only-child) {
    background: #f3f4f6;
}

/* Links in modal table */
.ewx-modal-body table a {
    color: #0073aa;
    text-decoration: underline;
}

.ewx-modal-body table a:hover {
    color: #005177;
}

/* Mobile responsiveness for modal tables */
@media (max-width: 768px) {
    .ewx-modal-body table {
        display: block;
        width: 100%;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        overflow: hidden;
        /* Ensure rounded corners work */
    }

    .ewx-modal-body table tbody {
        display: block;
        width: 100%;
    }

    .ewx-modal-body table tr {
        display: block;
        width: 100%;
        border-bottom: 1px solid #f3f4f6;
    }

    .ewx-modal-body table tr:last-child {
        border-bottom: none;
    }

    .ewx-modal-body table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
        padding: 8px 16px;
        border: none;
    }

    /* Styles for the Label (first cell) */
    .ewx-modal-body table td:first-child:not(:only-child) {
        width: 100%;
        background-color: #fff;
        /* Reset background */
        color: #64748b;
        /* Muted slate color */
        font-size: 11px;
        text-transform: uppercase;
        font-weight: 700;
        letter-spacing: 0.05em;
        padding-bottom: 2px;
        /* Pull value closer */
        padding-top: 12px;
    }

    /* Styles for the Value (second cell) */
    .ewx-modal-body table td+td {
        background-color: #fff;
        color: #0f172a;
        /* Dark slate */
        font-size: 15px;
        padding-top: 0;
        padding-bottom: 12px;
        word-break: break-word;
        /* Prevent overflow */
    }

    /* Section Headers on Mobile */
    .ewx-modal-body table tr td:only-child {
        background-color: #f1f5f9;
        color: #334155;
        font-size: 13px;
        padding: 10px 16px;
        border-bottom: 2px solid #e2e8f0;
        margin-top: 0;
        border-radius: 0;
        width: 100%;
    }

    /* Main Header (First Row) */
    .ewx-modal-body table tr:first-child td:only-child {
        background-color: #0b5ed7;
        color: #fff;
        font-size: 16px;
        text-align: center;
        padding: 16px;
        width: 100%;
        display: none;
        /*remove header*/
    }
}

/* ========================================
   Pagination Styles
   ======================================== */

.ewx-pagination {
    margin-top: 20px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.ewx-news-wrapper {
    position: relative;
    transition: opacity 0.3s ease;
}

.ewx-news-wrapper.ewx-loading {
    opacity: 0.5;
    pointer-events: none;
}

.ewx-news-wrapper.ewx-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: ewx-spin 1s linear infinite;
    z-index: 10;
}

@keyframes ewx-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.ewx-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.ewx-pagination .page-numbers:hover {
    background: #f4f4f4;
    border-color: #ccc;
}

.ewx-pagination .page-numbers.current {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.ewx-pagination .page-numbers.dots {
    border: none;
    padding: 8px 4px;
}

/* ========================================
   Responsive Styles
   ======================================== */

@media screen and (max-width: 768px) {

    .ewx-stock-table,
    .ewx-news-table {
        font-size: 13px;
    }

    .ewx-stock-table th,
    .ewx-stock-table td,
    .ewx-news-table th,
    .ewx-news-table td {
        padding: 8px 6px;
    }

    .ewx-modal-content {
        width: 95%;
        margin: 10% auto;
    }

    .ewx-modal-content h2 {
        font-size: 16px;
        padding: 15px 45px 15px 15px;
    }

    .ewx-modal-body {
        padding: 15px;
    }
}

/* ========================================
   Stock Ticker Widget Styles
   ======================================== */

.ewx-ticker-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    /* Centered alignment */
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    min-width: 140px;
    border: 1px solid #f0f0f0;
}

.ewx-ticker-top {
    display: flex;
    align-items: baseline;
    justify-content: center;
    /* Centered alignment */
    gap: 8px;
    margin-bottom: 2px;
}

.ewx-ticker-arrow {
    font-size: 14px;
}

.ewx-ticker-price {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.ewx-ticker-bottom {
    display: flex;
    gap: 6px;
    font-size: 14px;
    font-weight: 400;
}

.ewx-ticker-up {
    color: #22c55e;
    /* Green */
}

.ewx-ticker-down {
    color: #ef4444;
    /* Red */
}

.ewx-ticker-percent {
    opacity: 0.9;
}

/* ========================================
   Price Overview Grid Styles
   ======================================== */

.ewx-overview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    margin-bottom: 20px;
}

.ewx-overview-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ewx-overview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
}

.ewx-overview-item:last-child {
    border-bottom: none;
}

.ewx-ov-label {
    color: #64748b;
    font-weight: 500;
}

.ewx-ov-value {
    color: #1e293b;
    font-weight: 600;
    text-align: right;
}

@media screen and (max-width: 992px) {
    .ewx-overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (max-width: 600px) {
    .ewx-overview-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}