/* Custom Styles for DLS Cricket Calculator */

/* Print Styles */
@media print {
    /* Hide unnecessary elements when printing */
    header,
    footer,
    button,
    .no-print {
        display: none !important;
    }

    /* Hide the entire form and sidebar */
    .lg\:col-span-2 > div:first-child,
    .lg\:col-span-1 {
        display: none !important;
    }

    /* Ensure results are visible and well-formatted */
    body {
        background: white;
        margin: 0;
        padding: 10px;
        font-size: 10pt;
        line-height: 1.3;
    }

    .container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    /* Make results card take full width */
    #resultsCard {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        page-break-inside: avoid;
        display: block !important;
    }

    /* Results content */
    #resultsCard h2 {
        font-size: 12pt;
        margin-bottom: 6px;
        color: #000;
    }

    /* Main result box */
    #resultsCard > div:first-child {
        display: none; /* Hide the buttons row */
    }

    #mainResult {
        background: #2d7a3e !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        padding: 10px;
        margin-bottom: 8px;
        border-radius: 4px;
    }

    #mainResult h3 {
        font-size: 11pt;
        margin-bottom: 4px;
    }

    #mainResult div:nth-child(2) {
        font-size: 26pt !important;
        margin: 6px 0;
    }

    #mainResult p {
        font-size: 10pt;
        margin: 2px 0;
    }

    /* Resources boxes - make them more compact */
    .grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 8px;
    }

    .grid > div {
        padding: 8px !important;
        font-size: 9pt;
    }

    .grid h4 {
        font-size: 9pt;
        margin-bottom: 4px;
    }

    .grid > div > div {
        font-size: 16pt !important;
        margin: 3px 0;
    }

    .grid p {
        font-size: 8pt;
        margin-top: 2px;
    }

    /* Hide original details element in print */
    details {
        display: none !important;
    }

    /* Show print-only breakdown */
    #printBreakdown,
    .print-only-breakdown {
        display: block !important;
        border: 1px solid #ddd !important;
        border-radius: 3px;
        padding: 8px !important;
        margin-top: 8px !important;
        page-break-inside: avoid;
    }

    #printBreakdown h3 {
        font-size: 10pt !important;
        font-weight: bold !important;
        margin-bottom: 6px !important;
        margin-top: 0 !important;
        color: #000;
    }

    #printBreakdownContent,
    #printBreakdown #breakdownContent {
        display: block !important;
        margin-top: 0 !important;
        visibility: visible !important;
    }

    /* Ensure breakdown steps are visible */
    #printBreakdown .breakdown-step,
    .print-only-breakdown .breakdown-step {
        display: flex !important;
        visibility: visible !important;
        page-break-inside: avoid;
        margin-bottom: 5px !important;
        padding: 6px !important;
        border-left: 2px solid #2d7a3e !important;
        background-color: white !important;
    }

    .breakdown-step-number {
        width: 1.3rem !important;
        height: 1.3rem !important;
        font-size: 8pt !important;
        margin-right: 6px !important;
        line-height: 1.3rem !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        background-color: #2d7a3e !important;
        color: white !important;
        border-radius: 50%;
        font-weight: bold;
    }

    .breakdown-step-content {
        font-size: 8pt !important;
        flex: 1;
        display: block !important;
        visibility: visible !important;
    }

    .breakdown-step-content > div:first-child {
        font-size: 9pt !important;
        margin-bottom: 2px !important;
        font-weight: 600;
        display: block !important;
    }

    .breakdown-step-content > div:nth-child(2) {
        font-size: 11pt !important;
        margin: 2px 0 !important;
        font-weight: bold;
        color: #2d7a3e !important;
        display: block !important;
    }

    .breakdown-step-content > div:last-child {
        font-size: 7pt !important;
        margin-top: 1px !important;
        color: #666;
        display: block !important;
    }

    /* Add header for print */
    #resultsCard::before {
        content: "DLS Cricket Calculator - Calculation Results";
        display: block;
        font-size: 14pt;
        font-weight: bold;
        margin-bottom: 8px;
        padding-bottom: 6px;
        border-bottom: 2px solid #2d7a3e;
    }

    /* Add timestamp */
    #resultsCard::after {
        content: "Generated: " attr(data-timestamp);
        display: block;
        font-size: 7pt;
        color: #666;
        margin-top: 8px;
        padding-top: 6px;
        border-top: 1px solid #e5e7eb;
    }

    /* Force single page with minimal margins */
    @page {
        margin: 1.2cm 0.8cm;
        size: A4;
    }

    /* Ensure colors print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Show current status if present */
    #currentStatusResult {
        display: block !important;
        background: #fffbeb !important;
        border: 1px solid #fbbf24 !important;
        border-radius: 3px;
        padding: 8px !important;
        margin-bottom: 8px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    #currentStatusResult h4 {
        font-size: 10pt !important;
        font-weight: bold !important;
        margin-bottom: 4px !important;
        color: #000;
    }

    #currentStatusResult.hidden {
        display: none !important;
    }

    #currentStatusContent {
        font-size: 9pt !important;
    }

    #currentStatusContent p {
        font-size: 9pt !important;
        margin: 2px 0 !important;
    }

    #currentStatusContent .status-ahead {
        color: #10b981 !important;
    }

    #currentStatusContent .status-behind {
        color: #ef4444 !important;
    }

    #currentStatusContent .status-level {
        color: #f59e0b !important;
    }

    /* Tighten all margins and padding */
    h1, h2, h3, h4, h5, h6 {
        margin-top: 0;
        margin-bottom: 4px;
    }

    p {
        margin: 2px 0;
    }

    div {
        margin: 0;
    }
}

/* Smooth transitions */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Input focus states */
input:focus,
select:focus,
button:focus {
    outline: none;
}

/* Custom scrollbar for history */
#historyList::-webkit-scrollbar {
    width: 6px;
}

#historyList::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#historyList::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#historyList::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Toast animation */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

#toast.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

#toast.hide {
    animation: slideOut 0.3s ease-out;
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2d7a3e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* History item hover effect */
.history-item {
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-item:hover {
    background-color: #f9fafb;
    border-color: #2d7a3e;
}

/* Result card entrance animation */
#resultsCard.show {
    animation: fadeInUp 0.5s ease-out;
}

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

/* Error input state */
input.error,
select.error {
    border-color: #ef4444 !important;
    background-color: #fef2f2;
}

/* Error message */
.error-message {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Success state */
.success-border {
    border-color: #10b981 !important;
}

/* Disabled state */
input:disabled,
select:disabled,
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Breakdown steps styling */
.breakdown-step {
    display: flex;
    padding: 0.75rem;
    background-color: white;
    border-left: 3px solid #2d7a3e;
    border-radius: 0.25rem;
}

.breakdown-step-number {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2d7a3e;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    margin-right: 1rem;
}

.breakdown-step-content {
    flex: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

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

/* Custom checkbox styling */
input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: #2d7a3e;
}

/* Details/Summary styling */
details summary {
    list-style: none;
    user-select: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
}

details[open] summary::before {
    transform: rotate(90deg);
}

/* Badge styling for match format */
.format-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: #e8f5e9;
    color: #1b5e20;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Status indicators */
.status-ahead {
    color: #10b981;
    font-weight: 600;
}

.status-behind {
    color: #ef4444;
    font-weight: 600;
}

.status-level {
    color: #f59e0b;
    font-weight: 600;
}
