/**
 * supriyadigital.com Cost Estimator - Enhanced CSS
 * Features: Toast Notifications + Download History + Mobile Floating Icon + Unit Converter + BOQ
 */

/* Global Styles */
.ssd-cost-estimator-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 20px 0;
}

/* Header Card */
.estimator-header-card {
    border: none;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    margin-bottom: 30px;
}

.estimator-header-card .card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 30px;
}

.estimator-header-card .card-body {
    background: white;
    padding: 30px;
}

/* Success Toast Notification */
.success-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(76, 175, 80, 0.3);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    max-width: 350px;
    min-width: 280px;
}

.success-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.success-toast:hover {
    transform: translateX(0) translateY(-2px);
    box-shadow: 0 12px 40px rgba(76, 175, 80, 0.4);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-icon {
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}

.toast-message {
    flex-grow: 1;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Download History Panel (Desktop) */
.download-history-panel {
    position: fixed;
    top: 50%;
    right: -320px;
    transform: translateY(-50%);
    width: 300px;
    max-height: 400px;
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border-radius: 12px 0 0 12px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: 1px solid #e3e6f0;
    border-right: none;
}

.download-history-panel:hover {
    right: 0;
}

.history-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px 0 0 0;
    display: flex;
    justify-content: between;
    align-items: center;
}

.history-content {
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    background: white;
    border: 1px solid #e3e6f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-color: #4caf50;
}

.history-filename {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.filename-text {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    word-break: break-all;
}

.history-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.re-download-btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
}

.re-download-btn:hover {
    transform: scale(1.05);
}

/* Mobile Floating Icon */
.mobile-float-icon {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    border-radius: 50%;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
    z-index: 9999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    touch-action: none;
    user-select: none;
}

.mobile-float-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

.mobile-float-icon.dragging {
    transform: scale(1.15);
    box-shadow: 0 10px 30px rgba(76, 175, 80, 0.5);
    z-index: 10000;
}

.float-icon-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f44336;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

/* Mobile History Popup */
.mobile-history-popup {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    max-height: 70vh;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.mobile-history-popup.show {
    transform: translateY(0);
}

.mobile-history-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-history-content {
    padding: 15px 20px;
    max-height: 40vh;
    overflow-y: auto;
}

.mobile-history-footer {
    padding: 15px 20px;
    border-top: 1px solid #e3e6f0;
    background: #f8f9fa;
    text-align: center;
}

/* Unit Converter Styles */
.unit-converter-wrapper {
    position: relative;
}

.unit-converter-card {
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border: 2px solid #e3f2fd;
}

.unit-converter-card .card-header {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%) !important;
    border: none;
    border-radius: 12px 12px 0 0 !important;
    padding: 20px 25px;
}

/* Excel-Style Tabs */
.excel-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 0 20px;
    gap: 2px;
}

.excel-tab {
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 5px;
    position: relative;
}

.excel-tab:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.excel-tab.active {
    background: white;
    color: #2e7d32;
    border-color: #4caf50;
    transform: translateY(-2px);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.excel-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: white;
}

/* Conversion Content */
.conversion-content {
    background: white;
    min-height: 200px;
}

.conversion-panel {
    display: none;
}

.conversion-panel.active {
    display: block;
    animation: fadeInUp 0.3s ease-out;
}

/* Conversion Grid */
.conversion-grid {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: 1px;
    background: #dee2e6;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
}

.conversion-header {
    display: contents;
}

.conversion-row {
    display: contents;
}

.grid-cell {
    background: white;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    font-size: 13px;
}

.grid-cell.header {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    font-weight: bold;
    color: #0d47a1;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-align: center;
    justify-content: center;
    border-bottom: 2px solid #90caf9;
}

.grid-cell.unit {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

/* Conversion Input Fields */
.conversion-input {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    text-align: right;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    transition: all 0.3s ease;
}

.conversion-input:focus {
    border-color: #4caf50;
    box-shadow: 0 0 0 0.2rem rgba(76, 175, 80, 0.25);
    background: #f1f8e9;
}

.conversion-input:not(:placeholder-shown) {
    background: #e8f5e8;
    color: #2e7d32;
}

/* Copy Button */
.copy-btn {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
    min-width: 45px;
}

.copy-btn:hover {
    transform: scale(1.05);
}

/* Table Card */
.estimator-table-card {
    border: none;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.estimator-table-card .card-header {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    border: none;
    padding: 20px 30px;
}

/* Form Controls */
.form-control, .form-select {
    border: 2px solid #e3e6f0;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.form-control-lg {
    padding: 15px 20px;
    font-size: 16px;
}

/* DOUBLED ROW HEIGHT: Tall Form Controls */
.form-control-tall {
    padding: 16px 12px !important;
    font-size: 13px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
    transition: all 0.2s ease;
    height: auto;
    min-height: 50px;
}

.form-control-tall:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.1rem rgba(102, 126, 234, 0.25);
    background: #fff;
}

.form-control-tall.bg-light {
    background: #f8f9fc !important;
    color: #495057;
    font-weight: 600;
}

.form-control-tall.bg-success {
    background: #d4edda !important;
    color: #155724 !important;
    font-weight: bold;
}

/* DOUBLED ROW HEIGHT: Tall Row Styling */
.boq-tall-row {
    height: auto;
    min-height: 70px;
}

.boq-tall-row td {
    padding: 16px 8px !important;
    vertical-align: middle;
    height: auto;
    min-height: 70px;
}

/* DOUBLED ROW HEIGHT: Tall Input Groups */
.tall-input-group {
    padding: 16px 12px !important;
    font-size: 13px;
    background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
    border: 1px solid #dee2e6;
    color: #495057;
    font-weight: 600;
    min-height: 50px;
    display: flex;
    align-items: center;
}

/* DOUBLED ROW HEIGHT: Tall Action Buttons */
.tall-action-btn {
    padding: 12px 16px !important;
    font-size: 12px;
    border-radius: 4px;
    min-height: 46px;
}

/* Excel-Style Table */
.excel-table-container {
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 0;
}

.excel-style-table {
    font-size: 12px;
    margin-bottom: 0;
    background: white;
}

/* Table Header */
.table-header {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
}

.table-header th {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
    color: #0d47a1 !important;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 15px 8px;
    border: 2px solid #90caf9 !important;
    text-align: center;
    vertical-align: middle;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Column Widths */
.col-sno { width: 5%; min-width: 60px; }
.col-desc { width: 20%; min-width: 200px; }
.col-uom { width: 8%; min-width: 80px; }
.col-nos { width: 6%; min-width: 70px; }
.col-length { width: 8%; min-width: 80px; }
.col-width { width: 8%; min-width: 80px; }
.col-depth { width: 8%; min-width: 80px; }
.col-qty-each { width: 9%; min-width: 90px; }
.col-total-qty { width: 9%; min-width: 90px; }
.col-rate { width: 10%; min-width: 100px; }
.col-amount { width: 12%; min-width: 120px; }
.col-action { width: 5%; min-width: 60px; }

/* Table Rows */
.boq-data-row {
    transition: all 0.3s ease;
}

.boq-data-row:hover {
    background: rgba(102, 126, 234, 0.05) !important;
}

.boq-data-row:nth-child(even) {
    background: rgba(248, 250, 252, 0.8);
}

.boq-data-row td {
    border: 1px solid #e0e6ed !important;
    vertical-align: middle;
}

/* Serial Number */
.serial-number-cell {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.serial-number {
    font-size: 11px;
    padding: 8px 12px;
    background: #667eea !important;
    color: white;
    border-radius: 20px;
    font-weight: bold;
}

/* Sticky Grand Total Row */
.grand-total-sticky {
    position: sticky;
    bottom: 0;
    z-index: 99;
    background: white;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.grand-total-row {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%) !important;
    border-top: 3px solid #28a745 !important;
}

.grand-total-row td {
    border: 2px solid #28a745 !important;
    color: #155724 !important;
    font-weight: bold;
    font-size: 16px;
    padding: 15px !important;
}

#grand-total-display {
    font-family: 'Courier New', monospace;
    font-size: 20px !important;
    font-weight: bold;
    color: #155724 !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* Action Buttons */
.action-buttons {
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.btn {
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    padding: 12px 24px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.btn-primary:disabled {
    background: #6c757d;
    opacity: 0.6;
}

.btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.btn-success:hover {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
}

.btn-outline-success {
    border: 2px solid #4caf50;
    color: #4caf50;
}

.btn-outline-success:hover {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
    border-color: transparent;
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
}

.btn-outline-danger {
    border: 2px solid #f56565;
    color: #f56565;
}

.btn-outline-danger:hover {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    border-color: transparent;
    color: white;
}

/* Custom Scrollbar */
.excel-table-container::-webkit-scrollbar,
.history-content::-webkit-scrollbar,
.mobile-history-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.excel-table-container::-webkit-scrollbar-track,
.history-content::-webkit-scrollbar-track,
.mobile-history-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.excel-table-container::-webkit-scrollbar-thumb,
.history-content::-webkit-scrollbar-thumb,
.mobile-history-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

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

@keyframes pulseSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.copy-success {
    animation: pulseSuccess 0.3s ease-in-out;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .excel-style-table {
        font-size: 11px;
    }

    .table-header th {
        font-size: 9px;
        padding: 12px 6px;
    }

    .form-control-tall {
        padding: 14px 10px !important;
        min-height: 45px;
    }

    .boq-tall-row {
        min-height: 65px;
    }

    .boq-tall-row td {
        padding: 14px 6px !important;
        min-height: 65px;
    }

    .conversion-grid {
        grid-template-columns: 1fr 1fr 80px;
    }

    .grid-cell {
        padding: 10px 12px;
        font-size: 12px;
    }
}

@media (max-width: 1200px) {
    .ssd-cost-estimator-container {
        padding: 15px;
    }

    .excel-table-container {
        max-height: 50vh;
    }

    .estimator-header-card .card-body,
    .estimator-header-card .card-header {
        padding: 20px;
    }

    .form-control-tall {
        padding: 12px 8px !important;
        min-height: 42px;
    }

    .boq-tall-row {
        min-height: 60px;
    }

    .boq-tall-row td {
        padding: 12px 6px !important;
        min-height: 60px;
    }
}

@media (max-width: 768px) {
    .ssd-cost-estimator-container {
        padding: 10px;
    }

    .estimator-header-card .card-body,
    .estimator-header-card .card-header {
        padding: 15px;
    }

    .estimator-header-card .card-header h2 {
        font-size: 18px;
    }

    .table-header th {
        font-size: 8px;
        padding: 10px 3px;
    }

    .form-control-tall {
        padding: 10px 6px !important;
        font-size: 11px;
        min-height: 38px;
    }

    .boq-tall-row {
        min-height: 55px;
    }

    .boq-tall-row td {
        padding: 10px 4px !important;
        min-height: 55px;
    }

    .serial-number {
        font-size: 9px;
        padding: 6px 8px;
    }

    .tall-action-btn {
        padding: 8px 12px !important;
        font-size: 10px;
        min-height: 38px;
    }

    .excel-table-container {
        max-height: 40vh;
    }

    .grand-total-row td {
        font-size: 12px !important;
        padding: 10px !important;
    }

    #grand-total-display {
        font-size: 14px !important;
    }

    /* Mobile specific adjustments */
    .download-history-panel {
        display: none;
    }

    .mobile-float-icon {
        display: flex;
    }

    .mobile-history-popup {
        display: block;
    }

    .success-toast {
        bottom: 100px;
        right: 20px;
        left: 20px;
        max-width: none;
    }

    /* Responsive Converter */
    .excel-tabs {
        padding: 0 10px;
        flex-wrap: wrap;
    }

    .excel-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    .conversion-grid {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .conversion-row {
        display: grid;
        grid-template-columns: 1fr 1fr 60px;
        gap: 2px;
    }

    .grid-cell {
        padding: 8px 10px;
        font-size: 11px;
    }

    .conversion-input {
        padding: 6px 8px;
        font-size: 13px;
    }

    .copy-btn {
        padding: 6px 8px;
        font-size: 11px;
        min-width: 40px;
    }
}

@media (max-width: 576px) {
    .form-control-lg {
        padding: 10px 12px;
        font-size: 14px;
    }

    .btn-lg {
        padding: 10px 16px;
        font-size: 14px;
    }

    .action-buttons {
        padding: 15px;
    }

    .action-buttons .btn {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }

    .form-control-tall {
        padding: 8px 6px !important;
        min-height: 35px;
    }

    .boq-tall-row {
        min-height: 50px;
    }

    .boq-tall-row td {
        padding: 8px 3px !important;
        min-height: 50px;
    }

    .mobile-float-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }

    .float-icon-badge {
        width: 20px;
        height: 20px;
        font-size: 10px;
        top: -3px;
        right: -3px;
    }
}

/* Print Styles - Hide interactive elements */
@media print {
    .download-history-panel,
    .mobile-float-icon,
    .mobile-history-popup,
    .success-toast,
    .unit-converter-card,
    #unit-converter-section,
    .unit-converter-wrapper {
        display: none !important;
    }

    .ssd-cost-estimator-container {
        background: white !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }

    .btn, .modal, .action-buttons {
        display: none !important;
    }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }

    .form-control, .form-select {
        border: 2px solid #000;
    }

    .btn {
        border: 2px solid #000;
    }

    .excel-style-table th,
    .excel-style-table td {
        border: 1px solid #000 !important;
    }
}

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

/* Focus Management */
.form-control:focus,
.form-select:focus,
.btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Template Hidden */
template {
    display: none !important;
}
