﻿/*#region **** Introduction *****/
/*
    CSS for Productive Widgets styling
    Styling being fonts, colours, size (width and height), borders (including margins and padding).
    
    Applications should customise style by
     - cascading the styles and variables declared here in an application style sheet
     - setting attributes of components during Page and Widget design
     - writing application specific Productive Widgets components

    There is also pwstructure.css with structural CSS for factory components.  Whilst applications can
    subclass structural factory CSS it is recommended that they do not.

    Naming conventions
     - Style classes start with "pw"
     - CSS variables start with "--pw"
***************************************************************/

/*  Official names

    // This construct is a Rule (or Style Rule).
    selector {  
        property: value;  // Declaration.  In Productive Widgets often referred to as "A style".
    }
    // The HTML a style tag, Javascript style property and Productive Widgets Style property are all multiple declarations. 

    Some selectors
      span & pw-integer are Type Selectors
      .myclass & .pwsolo-edit are officially Classes, but in Productive Widgets are called Style Classes

    --pwsolo-edit is officially a Custom Property, but in Productive Widgets is called a CSS Variable
*/
/*#endregion */

/*#region **** Fonts *****/

/*
    The factory default font family and size are defined in the pwroot.css file.

    Factory components generally
     - do not change the font family
     - use smaller, larger or percentage to change font size
     
    Application custom of fonts
    For root font see comments in pwroot.css.
    Normal CSS techniques for variations from that.
*/
/*#endregion*/

/*#region **** Colours *****/

/*
    Colours are defined by CSS variables

    Colour CSS variables are in upper case without pw prefix

    In variable names
     - BG means background colour
     - TEXT means font colour

    Application can customise colours by
     - Cascade the pw- style classes defined below to override the colour CSS variables
     - Define their own style classes to override the colour CSS variables and apply as required
     - Set colour CSS variables directly on individual solo components at design time
*/

:root {
    /*** 
    Declaration of --pw variables with default values only
    Rules for :root, html and body go in pwroot.css
    ***/

    --SOLO-TEXT-EDITABLE: "";
    --SOLO-TEXT-READONLY: "";
    --SOLO-TEXT-DISABLED: gray;
    --SOLO-BG-INVALID: lightpink; /* } */
    --SOLO-BG-EDITABLE: lightcyan; /* } Applied to edit elements by factory style classes */
    --SOLO-BG-READONLY: ""; /* } */
    --SOLO-BG-DISABLED: ""; /* } */
    --CAPTION-TEXT: cornflowerblue;
    --CAPTION-TEXT-DISABLED: var(--SOLO-TEXT-DISABLED);
    --CAPTION-BG: ""; /* } Applied to caption area, not just caption label */
    --CAPTION-BG-DISABLED: ""; /* } */
    --SUBCAPTION-TEXT: var(--CAPTION-TEXT); /* } For labels before elements, e.g. "from" and "to" in a date range component. */
    --SUBCAPTION-TEXT-DISABLED: var(--CAPTION-TEXT-DISABLED);
    --COMPOUND-BG: "";
    --H1-TEXT: var(--TEXT);
    --H2-TEXT: mediumblue;
}

/*
    One of these classes is applied to solo components
    pwsolo-editable
    pwsolo-editable-invalid
    pwsolo-readonly
    pwsolo-readonly-invalid
    pwsolo-disabled
    pwsolo-disabled-invalid
    
    Within a solo component there is a PwCaption and one of more PwActives.
    PwCaption wraps the Caption label.  PwActive wraps an HTML component, usually interterative such as <input> or <button>
    One of these is applied to the PwCaption 
        pwcaption // in its normal position
        pwcaption-top // when at the top so PwActive has full width under it
    One of these is applied to the each PwActive
        pwactive  // to a pw sub-component which wraps each HTML element in the non-caption area, e.g. <input>, <button>
        pwactive-usebackground  // to a pwactive sub-component containing elements that do not support background colour, e.g. checkboxes
    One of these to the HTML element within a PwActivw
        pwedit  // to editable components such as <input>, <textarea> within a pwactive sub-component
        pwcheck  // to editable elements which do not have text or background, e.g. checkboxes and radio buttons
        pwbutton  // to buttons within a pwactive sub-component
        pwread  // to components that are naturally read only, e.g. <label>
    If the PwActive includes a pwsubcaption this applied to <label> for it    
        pwsubcaption 
*/

/* Rules for captions, which in effect have 2 states */

.pwsolo-editable, .pwsolo-editable-invalid, .pwsolo-readonly, .pwsolo-readonly-invalid {
    .pwcaption, .pwcaption-top {   /* span:first-of-type {  /* Only apply to span for caption, not any other spans that might be in the control proper */
        color: var(--CAPTION-TEXT);
        background-color: var(--CAPTION-BG);
    }
}

.pwsolo-disabled, .pwsolo-disabled-invalid {
    .pwcaption, .pwcaption-top {
        color: var(--CAPTION-TEXT-DISABLED);
        background-color: var(--CAPTION-BG-DISABLED);
    }
}

/* Rules for active sub elements, for styles not affected by invalid  */

.pwsolo-editable, .pwsolo-editable-invalid {
    .pwedit, .pwread {
        color: var(--SOLO-TEXT-EDITABLE);
    }
    .pwbutton, .pwsubcaption {
        color: var(--SUBCAPTION-TEXT-EDITABLE);
    }
}

.pwsolo-readonly, .pwsolo-readonly-invalid {
    .pwedit, pwread {
        color: var(--SOLO-TEXT-READONLY);
    }
    .pwbutton, .pwsubcaption {
        color: var(--SUBCAPTION-TEXT-READONLY);
    }
}

.pwsolo-disabled, .pwsolo-disabled-invalid {
    .pwedit, pwread {
        color: var(--SOLO-TEXT-DISABLED);
    }
    .pwbutton, .pwsubcaption {
        color: var(--SUBCAPTION-TEXT-DISABLED);
    }
}

/* Rules for active sub elements, for styles affected by invalid  */

.pwsolo-editable-invalid, .pwsolo-readonly-invalid, .pwsolo-disabled-invalid {
    .pwactive-usebackground {
        background-color: var(--SOLO-BG-INVALID);
    }
    .pwedit {
        background-color: var(--SOLO-BG-INVALID);
    }
}

.pwsolo-editable, .pwsolo-readonly, .pwsolo-disabled {
    .pwactive-usebackground {
        background-color: unset;
    }
}

.pwsolo-editable .pwedit {
    background-color: var(--SOLO-BG-EDITABLE);
}

.pwsolo-readonly .pwedit {
    background-color: var(--SOLO-BG-READONLY);
}

.pwsolo-disabled .pwedit {
    background-color: var(--SOLO-BG-DISABLED);
}

/* Empty date input (class pwempty, see trackEmptyDate in pwInput.ts): hide the browser's date format text,
   e.g. "mm/dd/yyyy", while the input is not focused, so an empty date looks empty. */
input[type="date"].pwempty:not(:focus) {
    color: transparent;
}

/* Rules for non-custom HTML elements */

h1 {
    color: var(--H1-TEXT);
}

h2 {
    color: var(--H2-TEXT);
}

/*#endregion*/

/*#region **** Widths *****/
    
    /*  Application customisation of widths
    Applications can 
     - Cascade .pwform-widths and .pwgrid-widths
     - Define their own style classes to override the width CSS variables and apply as required
     - Set widths directly on individual solo components at design time
    */

:root {
    /*** 
    Declaration of --pw variables with default values only
    Rules for :root, html and body go in pwroot.css
    ***/
    /* For widths "px" suffix is compulsory.  Browsers erratically require and assume it.
       Even if a plain number works in a situation, it might not work in another. 

    */

    --pwcaption-width: 124px; /* Solo component Captions.  + 4px right margin */
    --pwsolo-width: ""; /* e.g. Date, money, number */
    --pwsolo-width-wide: ""; /* e.g. Text and drop down.  
                                With caption fills one column of 2-column form. 
                                Should be 246px, but too wide in 2-column form.  Don't know why. */
    --pwsolo-width-full: 100%; /* e.g. Memo.  
                                Full width, esp when double column form */
}

.pwform {
    /*** 
    For solo components that are direct children of a form
    Can be used in other places, notably within lists.     
    ***/

    --pwsolo-width: 101px;      /* e.g. Date, money, number */
    --pwsolo-width-wide: 244px; /* e.g. Text and drop down.  
                                 With caption fills one column of 2-column form. 
                                 Should be 246px, but too wide in 2-column form.  Don't know why. */
}

.pwgrid {
    /*** 
    For solo components that are within a gird, and thus not displaying their caption
    Can be used in other places, notably within lists.
    ***/

    --pwsolo-width: 75px; /* e.g. Date, money, number */
    --pwsolo-width-wide: 124px; /* e.g. Text and drop down.  
                                 With caption fills one column of 2-column form. 
                                 Should be 246px, but too wide in 2-column form.  Don't know why. */
    --pwsolo-width-full: 244px; /* e.g. Memo.  
                                 100% not appropriate within a grid */
}

.pwtabcontrol-button {
    /*** PeTabControl buttons ***/
}

.pwtabcontrol-buttonactive {
    /*** PeTabControl button for currently active tab ***/
    .pwbutton {
        background-color: var(--SOLO-BG-EDITABLE);
    }
}

.pwtabcontrol-buttoninactive {
    /*** PeTabControl button other tabs ***/
    .pwbutton {
    }
}

/*#endregion*/

.pwflex-break {
    width: 100%;
    height: 0;
}



