/* ============================================
   REVERSE DUE DATE CALCULATOR - CSS
   Version 1.0
============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

.rddc-wrap {
    --pink:        #F72585;
    --purple:      #7209B7;
    --violet:      #560BAD;
    --blue:        #480CA8;
    --grad:        linear-gradient(135deg, #F72585 0%, #7209B7 100%);
    --grad-soft:   linear-gradient(135deg, rgba(247,37,133,0.08) 0%, rgba(114,9,183,0.08) 100%);
    --white:       #FFFFFF;
    --bg:          #F8F4FF;
    --card-bg:     #FFFFFF;
    --border:      rgba(114,9,183,0.12);
    --text:        #1A1A2E;
    --text-muted:  #6B7280;
    --shadow-card: 0 32px 80px rgba(114,9,183,0.18), 0 8px 24px rgba(247,37,133,0.10);
    --shadow-btn:  0 12px 32px rgba(247,37,133,0.45);
    --radius-xl:   24px;
    --radius-lg:   16px;
    --radius-md:   12px;
    --radius-sm:   8px;
    font-family: 'Inter', sans-serif;
    position: relative;
    padding: 40px 16px;
    background: var(--bg);
    min-height: 100%;
}

.rddc-blob { position: absolute; border-radius: 50%; filter: blur(60px); pointer-events: none; z-index: 0; }
.rddc-blob-1 { width: 300px; height: 300px; background: rgba(247,37,133,0.12); top: -60px; left: -80px; }
.rddc-blob-2 { width: 250px; height: 250px; background: rgba(114,9,183,0.10); bottom: 40px; right: -60px; }
.rddc-blob-3 { width: 180px; height: 180px; background: rgba(72,12,168,0.08); top: 50%; left: 50%; transform: translate(-50%,-50%); }

.rddc-card {
    position: relative;
    z-index: 1;
    max-width: 540px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* ---- Header ---- */
.rddc-header { background: var(--grad); padding: 28px 30px; display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden; }
.rddc-header::after { content: ''; position: absolute; width: 200px; height: 200px; background: rgba(255,255,255,0.06); border-radius: 50%; top: -80px; right: -60px; }
.rddc-header::before { content: ''; position: absolute; width: 120px; height: 120px; background: rgba(255,255,255,0.04); border-radius: 50%; bottom: -40px; left: 30%; }
.rddc-header-icon { width: 52px; height: 52px; background: rgba(255,255,255,0.18); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.25); }
.rddc-header-icon svg { width: 28px; height: 28px; }
.rddc-header-text { flex: 1; min-width: 0; }
.rddc-header-text h2 { color: #FFFFFF; font-size: 18px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.25; }
.rddc-header-text p { color: rgba(255,255,255,0.75); font-size: 12.5px; font-weight: 400; margin-top: 3px; }

.rddc-history-btn { width: 40px; height: 40px; background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.25); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; position: relative; z-index: 2; transition: background 0.2s; }
.rddc-history-btn:hover { background: rgba(255,255,255,0.28); }

/* ---- History Panel ---- */
.rddc-history-panel { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; background: #FAFAFF; border-bottom: 1px solid var(--border); }
.rddc-history-panel.rddc-history-open { max-height: 320px; overflow-y: auto; }
.rddc-history-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px 8px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.rddc-history-clear { background: none; border: none; color: var(--pink); font-size: 11px; font-weight: 700; cursor: pointer; }
.rddc-history-list { padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.rddc-history-empty { font-size: 13px; color: var(--text-muted); padding: 12px 0; text-align: center; }
.rddc-history-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: white; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.rddc-history-item-date { font-size: 13px; font-weight: 700; color: var(--text); }
.rddc-history-item-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.rddc-history-item-load { background: var(--grad-soft); border: none; color: var(--purple); font-size: 12px; font-weight: 700; padding: 6px 14px; border-radius: 100px; cursor: pointer; flex-shrink: 0; }
.rddc-history-item-load:hover { background: var(--grad); color: white; }

/* ---- Body ---- */
.rddc-body { padding: 24px 30px 28px; display: flex; flex-direction: column; gap: 20px; }
.rddc-intro { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; background: var(--grad-soft); border-radius: var(--radius-md); padding: 12px 14px; }
.rddc-intro strong { color: var(--text); }

.rddc-step-label { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.rddc-step-label span { font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: 0.1px; }
.rddc-hint { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-top: 8px; }

.rddc-help-btn {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--grad-soft);
    border: 1px solid var(--border);
    color: var(--purple);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}
.rddc-help-btn:hover { background: var(--grad); color: white; border-color: transparent; }

/* ---- Date Input ---- */
.rddc-date-wrap { position: relative; display: flex; align-items: center; }
.rddc-date-icon { position: absolute; left: 14px; color: var(--purple); display: flex; align-items: center; pointer-events: none; z-index: 1; }
.rddc-date-icon svg { width: 20px; height: 20px; }
.rddc-date-wrap input[type="date"] {
    width: 100%; padding: 14px 16px 14px 46px;
    border: 2px solid var(--border); border-radius: var(--radius-md);
    font-size: 15px; font-family: 'Inter', sans-serif; font-weight: 500;
    color: var(--text); background: #FAFAFF; cursor: pointer;
    appearance: none; -webkit-appearance: none; outline: none;
    transition: all 0.25s ease;
}
.rddc-date-wrap input[type="date"]:focus { border-color: var(--pink); background: white; box-shadow: 0 0 0 4px rgba(247,37,133,0.08); }

/* ---- Plain / Duration Input ---- */
.rddc-plain-input {
    width: 100%; padding: 14px 16px;
    border: 2px solid var(--border); border-radius: var(--radius-md);
    font-size: 15px; font-family: 'Inter', sans-serif; font-weight: 600;
    color: var(--text); background: #FAFAFF; outline: none;
    transition: all 0.25s ease;
}
.rddc-plain-input:focus { border-color: var(--pink); background: white; box-shadow: 0 0 0 4px rgba(247,37,133,0.08); }

.rddc-duration-row { display: flex; gap: 8px; align-items: flex-start; }
.rddc-duration-values { display: flex; gap: 6px; flex: 1; min-width: 0; }
.rddc-duration-values .rddc-plain-input { flex: 1; min-width: 0; }
.rddc-duration-labels { display: none; gap: 6px; margin-top: 6px; padding-right: 118px; }
.rddc-duration-labels span { flex: 1; text-align: center; font-size: 10.5px; color: var(--text-muted); font-weight: 600; }
.rddc-select-wrap { position: relative; flex-shrink: 0; width: 130px; }
.rddc-select-wrap select {
    width: 100%; padding: 14px 30px 14px 12px;
    border: 2px solid var(--border); border-radius: var(--radius-md);
    font-size: 12px; font-family: 'Inter', sans-serif; font-weight: 600;
    color: var(--text); background: #FAFAFF; cursor: pointer;
    appearance: none; -webkit-appearance: none; outline: none;
    transition: all 0.25s ease;
}
.rddc-select-wrap select:focus { border-color: var(--pink); background: white; box-shadow: 0 0 0 4px rgba(247,37,133,0.08); }
.rddc-select-arrow { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--purple); pointer-events: none; }

/* ---- Calculate / Clear Buttons ---- */
#rddc_btn {
    width: 100%; padding: 16px 24px;
    background: var(--grad); color: white; border: none; border-radius: var(--radius-md);
    font-size: 16px; font-weight: 700; font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-btn);
}
#rddc_btn::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent); opacity: 0; transition: opacity 0.3s; }
#rddc_btn:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(247,37,133,0.50); }
#rddc_btn:hover::before { opacity: 1; }
.rddc-btn-text { font-size: 16px; font-weight: 700; }
.rddc-btn-icon { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: rgba(255,255,255,0.20); border-radius: 50%; }

.rddc-clear-btn {
    width: 100%; padding: 10px;
    background: none; border: none;
    color: var(--text-muted); font-size: 12.5px; font-weight: 600;
    font-family: 'Inter', sans-serif; cursor: pointer;
    text-decoration: underline;
}
.rddc-clear-btn:hover { color: var(--pink); }

/* ---- Help Popover ---- */
.rddc-help-overlay { display: none; position: fixed; inset: 0; background: rgba(26,26,46,0.55); z-index: 9999; align-items: center; justify-content: center; padding: 20px; }
.rddc-help-overlay.rddc-help-open { display: flex; }
.rddc-help-popover { background: white; border-radius: var(--radius-lg); padding: 24px; max-width: 360px; width: 100%; box-shadow: 0 24px 60px rgba(0,0,0,0.3); }
.rddc-help-popover-title { font-size: 16px; font-weight: 800; color: var(--pink); margin-bottom: 10px; }
.rddc-help-popover-text { font-size: 13.5px; color: var(--text); line-height: 1.65; margin-bottom: 18px; }
.rddc-help-close { width: 100%; padding: 10px; background: var(--grad); color: white; border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif; cursor: pointer; }

/* ---- Result Section ---- */
.rddc-result {
    display: none; opacity: 0; transform: translateY(16px);
    transition: all 0.45s cubic-bezier(0.34,1.56,0.64,1);
    border-top: 1px solid var(--border);
    padding: 28px 30px;
    background: linear-gradient(180deg, rgba(247,37,133,0.02) 0%, rgba(114,9,183,0.03) 100%);
}
.rddc-result-visible { opacity: 1 !important; transform: translateY(0) !important; }
.rddc-result-header { display: flex; justify-content: center; margin-bottom: 20px; }
.rddc-result-badge { background: var(--grad); color: white; padding: 6px 18px; border-radius: 100px; font-size: 13px; font-weight: 700; letter-spacing: 0.5px; box-shadow: 0 4px 14px rgba(247,37,133,0.30); }

/* Result Grid */
.rddc-result-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.rddc-result-block {
    background: white; border: 1.5px solid var(--border); border-radius: var(--radius-md);
    padding: 16px 18px; display: flex; align-items: center; gap: 14px;
    transition: all 0.25s ease;
}
.rddc-result-block.rddc-result-source { border-color: var(--pink); background: var(--grad-soft); }
.rddc-result-block-icon { font-size: 24px; flex-shrink: 0; width: 44px; height: 44px; background: var(--grad-soft); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.rddc-result-block.rddc-result-source .rddc-result-block-icon { background: white; }
.rddc-result-block-label { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
.rddc-result-block-val { font-size: 15px; color: var(--text); font-weight: 800; }
.rddc-result-note { font-size: 11px; color: var(--text-muted); line-height: 1.55; font-style: italic; margin-bottom: 20px; }

/* Export Buttons */
.rddc-export-row { display: flex; gap: 12px; }
.rddc-export-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 14px; background: white; border: 1.5px solid var(--border); border-radius: var(--radius-md);
    font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif;
    color: var(--purple); cursor: pointer;
    transition: all 0.25s ease;
}
.rddc-export-btn:hover { border-color: var(--pink); background: var(--grad-soft); color: var(--pink); transform: translateY(-1px); }
.rddc-export-btn svg { flex-shrink: 0; }

/* ---- Footer ---- */
.rddc-footer { display: flex; align-items: flex-start; gap: 8px; padding: 16px 30px 24px; font-size: 11px; color: var(--text-muted); line-height: 1.6; border-top: 1px solid var(--border); background: #FAFAFF; }
.rddc-footer svg { flex-shrink: 0; margin-top: 2px; color: var(--purple); }

/* ---- Mobile ---- */
@media (max-width: 580px) {
    .rddc-wrap { padding: 20px 10px; }
    .rddc-card { border-radius: var(--radius-lg); }
    .rddc-header { padding: 22px 20px; }
    .rddc-body { padding: 20px 20px 22px; gap: 18px; }
    .rddc-result { padding: 22px 20px; }
    .rddc-footer { padding: 14px 20px 20px; }
    .rddc-header-text h2 { font-size: 16px; }
    .rddc-export-row { flex-direction: column; }
    .rddc-history-item { flex-direction: column; align-items: flex-start; gap: 8px; }
    .rddc-history-item-load { align-self: flex-end; }
    .rddc-result-block { padding: 14px; }
    .rddc-result-block-val { font-size: 13px; }
}
