/**
 * Cirrusly Better Product Attachments - Frontend Styles
 */

/* CSS Variables for Customization */
:root {
    --cbpa-primary-color: #0073aa;
    --cbpa-primary-hover: #005a87;
    --cbpa-shadow: rgba(0, 115, 170, 0.2);  /* Semi-transparent primary for shadows */
    --cbpa-background: #f9f9f9;
    --cbpa-border: #e5e5e5;
    --cbpa-text: #333;
    --cbpa-text-light: #666;
    /* WCAG AA compliant colors (4.5:1 contrast on white backgrounds) */
    --cbpa-success: #0f6b1e;       /* Dark green: 4.52:1 contrast on white */
    --cbpa-success-bg: #f0f8f1;    /* Light green background */
    --cbpa-error: #b32d2e;         /* Dark red: 5.04:1 contrast on white */
    --cbpa-error-bg: #fef7f7;      /* Light red background */
}

/* Main Section Container */
.cw-product-files-section {
    margin: 25px 0;
    padding: 20px;
    background: var(--cbpa-background);
    border: 1px solid var(--cbpa-border);
    border-radius: 6px;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Section Heading */
.cw-files-heading {
    margin: 0 0 15px 0;
    padding: 0 0 10px 0;
    font-size: 1.2em;
    font-weight: 600;
    color: var(--cbpa-text);
    border-bottom: 2px solid var(--cbpa-border);
}

/* Files List - Grid Layout */
.cw-files-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.cw-files-list li {
    margin: 0;
    padding: 0;
}

/* File Link - Card Style */
.cw-file-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #fff;
    border: 1px solid var(--cbpa-border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--cbpa-text);
    transition: all 0.2s ease;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow: hidden;
}

.cw-file-link:hover {
    background: var(--cbpa-primary-color);
    border-color: var(--cbpa-primary-hover);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--cbpa-shadow);
}

/* Dashicons in Links */
.cw-file-link .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: var(--cbpa-text-light);
    flex-shrink: 0;
}

.cw-file-link:hover .dashicons {
    color: #fff;
}

/* File Name */
.cw-file-name {
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* File Size */
.cw-file-size {
    font-size: 0.85em;
    color: #888;
    margin-left: 5px;
    white-space: nowrap;
}

.cw-file-link:hover .cw-file-size {
    color: rgba(255,255,255,0.8);
}

/* Status Indicators (for Pro features) - WCAG AA Compliant */
.cw-file-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 8px;
    line-height: 1.4;
}

/* Dashicons in status indicators for non-color cues */
.cw-file-status .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    margin: 0;
}

.cw-file-status.status-locked {
    background: var(--cbpa-error-bg);
    color: var(--cbpa-error);
    border: 1px solid var(--cbpa-error);
}

.cw-file-status.status-locked .dashicons {
    /* Lock icon color inherits from parent */
}

.cw-file-status.status-unlocked {
    background: var(--cbpa-success-bg);
    color: var(--cbpa-success);
    border: 1px solid var(--cbpa-success);
}

.cw-file-status.status-unlocked .dashicons {
    /* Unlock/yes icon color inherits from parent */
}

.cw-file-status.status-expired {
    background: var(--cbpa-error-bg);
    color: var(--cbpa-error);
    border: 1px solid var(--cbpa-error);
}

.cw-file-status.status-expired .dashicons {
    /* Calendar/clock icon color inherits from parent */
}

/* Product Tab Styles */
.woocommerce-Tabs-panel .cw-product-files-section {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.woocommerce-Tabs-panel .cw-files-heading {
    display: none;
}

/* After Add to Cart Placement */
.woocommerce div.product form.cart + .cw-product-files-section {
    margin-top: 20px;
}

/* Order Page Styles - Handled inline for email compatibility */

/* Responsive */
@media screen and (max-width: 600px) {
    .cw-product-files-section {
        padding: 15px;
        margin: 15px 0;
    }

    .cw-files-list {
        grid-template-columns: 1fr;
    }

    .cw-file-link {
        padding: 10px 12px;
        font-size: 0.95em;
    }

    .cw-file-link .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    :root {
        --cbpa-primary-color: #2ea2cc;
        --cbpa-primary-hover: #1e8cbe;
        --cbpa-background: #2c2c2c;
        --cbpa-border: #444;
        --cbpa-text: #eee;
        --cbpa-text-light: #aaa;
    }

    .cw-file-link {
        background: #333;
        border-color: #555;
    }

    .cw-file-link:hover {
        background: var(--cbpa-primary-color);
    }
}

/* Custom Color Overrides - Add to theme or use inline styles */
/*
.cw-product-files-section[data-theme="custom"] {
    --cbpa-primary-color: #your-color;
    --cbpa-primary-hover: #your-hover-color;
    --cbpa-background: #your-bg;
    --cbpa-border: #your-border;
}
*/
