* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Accessibility - Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #0284c7;
    color: white;
    padding: 8px 16px;
    z-index: 100;
    text-decoration: none;
    border-radius: 0 0 5px 0;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* Visually Hidden (for screen readers only) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Noscript Warning */
.noscript-warning {
    background: #fef2f2;
    color: #991b1b;
    padding: 15px;
    text-align: center;
    border-bottom: 2px solid #f87171;
    font-weight: 500;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Layout */
.page-wrapper {
    max-width: 1300px;
    margin: 0 auto;
}

/* Ad Spaces */
.ad-banner {
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

.ad-banner-middle {
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Top Row: Calculator + Rates Table side by side */
.top-row {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 1000px) {
    .top-row {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .top-row .container {
        flex: 1;
        min-width: 400px;
        max-width: 500px;
        display: flex;
        flex-direction: column;
    }

    .top-row .rates-container {
        flex: 1.5;
        min-width: 500px;
        max-width: 700px;
    }

    .top-row .result {
        flex-grow: 1;
        display: none;
        flex-direction: column;
        justify-content: center;
    }

    .top-row .result.show {
        display: flex;
    }
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 1.8rem;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

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

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

input[type="number"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e1e1;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #0ea5e9;
}

.period-group {
    display: flex;
    gap: 10px;
}

.period-group input {
    flex: 2;
}

.period-group select {
    flex: 1;
}

/* Button */
button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 10px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(14, 165, 233, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Result Section */
.result {
    margin-top: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    border-radius: 15px;
    display: none;
}

.result.show {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
}

.result-item:last-child {
    border-bottom: none;
    padding-top: 15px;
    margin-top: 5px;
}

.result-item span:first-child {
    color: #666;
}

.result-item span:last-child {
    font-weight: 600;
    color: #333;
}

.result-item.total span:last-child {
    color: #0284c7;
    font-size: 1.3rem;
}

/* Input Prefix/Suffix */
.input-prefix {
    position: relative;
}

.input-prefix span {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
}

.input-prefix input {
    padding-left: 30px;
}

.input-suffix {
    position: relative;
}

.input-suffix span {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
}

.input-suffix input {
    padding-right: 35px;
}

/* Table Section */
.table-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    display: none;
    overflow-x: auto;
}

.table-container.show {
    display: block;
    animation: fadeIn 0.5s ease;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.breakdown-table th,
.breakdown-table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid #e1e1e1;
}

.breakdown-table th:first-child,
.breakdown-table td:first-child {
    text-align: left;
}

.breakdown-table th {
    background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
    color: white;
    font-weight: 600;
}

.breakdown-table tr:hover {
    background-color: #f5f7fa;
}

.breakdown-table tr:last-child {
    font-weight: 600;
    background-color: #f0f4ff;
}

.breakdown-table tr:last-child:hover {
    background-color: #e5ebff;
}

/* Calculation History Section */
.history-container {
    display: none;
}

.history-container.show {
    display: block;
}

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

.history-header h2,
.history-header h3 {
    margin-bottom: 0;
    font-size: 1.3rem;
}

.clear-btn {
    width: auto;
    padding: 8px 16px;
    font-size: 0.85rem;
    margin-top: 0;
    background: #ef4444 !important;
    cursor: pointer !important;
}

.clear-btn:hover {
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
}

.clear-btn:disabled {
    background: #ef4444 !important;
}

.history-table-wrapper {
    overflow-x: auto;
    max-height: 250px;
    overflow-y: auto;
}

.history-table {
    font-size: 0.9rem;
}

.history-table th,
.history-table td {
    white-space: nowrap;
}

/* Bank Rates Table Section */
.rates-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    display: flex;
    flex-direction: column;
}

.rates-container h2 {
    text-align: center;
    margin-bottom: 5px;
}

.rates-subtitle {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.rates-table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid #e1e1e1;
}

.rates-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 800px;
}

.rates-table th,
.rates-table td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid #e1e1e1;
    white-space: nowrap;
}

.rates-table th {
    background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 2;
}

.rates-table th.sticky-col {
    left: 0;
    z-index: 3;
}

.rates-table td.sticky-col {
    position: sticky;
    left: 0;
    background: white;
    font-weight: 600;
    color: #333;
    z-index: 1;
    border-right: 2px solid #e1e1e1;
}

.rates-table tbody tr:hover {
    background-color: #f0f9ff;
}

.rates-table tbody tr:hover td.sticky-col {
    background-color: #f0f9ff;
}

.rates-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

.rates-table tbody tr:nth-child(even) td.sticky-col {
    background-color: #f8fafc;
}

.rates-disclaimer {
    font-size: 0.75rem;
    color: #888;
    text-align: center;
    margin-top: 10px;
    font-style: italic;
}

/* Footer */
.footer {
    text-align: center;
    color: #0284c7;
    padding: 20px;
    margin-top: 20px;
    font-size: 0.9rem;
}

.footer p {
    margin: 5px 0;
}

.footer a {
    color: #0284c7;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer-links {
    margin-top: 10px;
}

.footer-links a {
    margin: 0 5px;
}

/* Site Header */
.site-header {
    text-align: center;
    padding: 30px 20px 20px;
    margin-bottom: 10px;
}

.site-header h1 {
    font-size: 2rem;
    color: #0284c7;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.site-header .tagline {
    font-size: 1.1rem;
    color: #555;
    max-width: 600px;
    margin: 0 auto;
}

.site-header .intro-text {
    font-size: 0.95rem;
    color: #666;
    max-width: 800px;
    margin: 15px auto 0;
    line-height: 1.6;
}

.site-header .intro-text strong {
    color: #0284c7;
}

/* FAQ Section */
.faq-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    margin-top: 20px;
}

.faq-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.faq-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e1e1e1;
}

.faq-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.faq-question {
    color: #0284c7;
    font-size: 1.1rem;
    margin-bottom: 10px;
    cursor: pointer;
}

.faq-answer {
    color: #555;
    line-height: 1.7;
    font-size: 0.95rem;
}

/* Info Section */
.info-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    margin-top: 20px;
}

.info-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.info-container h3 {
    color: #0284c7;
    font-size: 1.1rem;
    margin: 20px 0 10px;
}

.info-container p {
    color: #555;
    line-height: 1.7;
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.info-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.info-block {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    padding: 20px;
    border-radius: 10px;
}

.info-block h3 {
    margin-top: 0;
    font-size: 1rem;
}

.info-block p {
    margin-bottom: 0;
    font-size: 0.9rem;
}

/* ===================
   RESPONSIVE DESIGN
   =================== */

/* Mobile phones (up to 480px) */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container,
    .rates-container,
    .table-container {
        padding: 20px;
        border-radius: 15px;
    }

    h1 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }

    h2 {
        font-size: 1.2rem;
    }

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

    input[type="number"],
    select {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .input-prefix input {
        padding-left: 26px;
    }

    button {
        padding: 12px;
        font-size: 1rem;
    }

    .result {
        padding: 20px;
    }

    .result-item.total span:last-child {
        font-size: 1.1rem;
    }

    .rates-table {
        font-size: 0.75rem;
    }

    .rates-table th,
    .rates-table td {
        padding: 8px 6px;
    }

    .rates-table-wrapper {
        max-height: 300px;
    }

    .breakdown-table th,
    .breakdown-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .history-header h2,
    .history-header h3 {
        font-size: 1.1rem;
    }

    .clear-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .history-table {
        font-size: 0.75rem;
    }

    .history-table-wrapper {
        max-height: 200px;
    }

    .footer {
        font-size: 0.8rem;
        padding: 15px;
    }

    .site-header {
        padding: 20px 15px 15px;
    }

    .site-header h1 {
        font-size: 1.4rem;
    }

    .site-header .tagline {
        font-size: 0.9rem;
    }

    .site-header .intro-text {
        font-size: 0.85rem;
        margin: 10px auto 0;
    }

    .faq-container,
    .info-container {
        padding: 20px;
    }

    .faq-container h2,
    .info-container h2 {
        font-size: 1.2rem;
    }

    .faq-question {
        font-size: 1rem;
    }

    .faq-answer {
        font-size: 0.85rem;
    }

    .info-content {
        grid-template-columns: 1fr;
    }
}

/* Tablets (481px to 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    body {
        padding: 15px;
    }

    .container,
    .rates-container,
    .table-container {
        padding: 30px;
    }

    h1 {
        font-size: 1.6rem;
    }

    .site-header h1 {
        font-size: 1.7rem;
    }

    .rates-table {
        font-size: 0.8rem;
    }

    .rates-table-wrapper {
        max-height: 350px;
    }

    .faq-container,
    .info-container {
        padding: 30px;
    }

    .info-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small laptops / Large tablets (769px to 999px) */
@media (min-width: 769px) and (max-width: 999px) {
    .page-wrapper {
        max-width: 800px;
    }

    .rates-table-wrapper {
        max-height: 400px;
    }
}
